From eb559970846f0fa27f1f25c482cd07210a56f4b1 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Sun, 25 Aug 2019 16:18:24 +0200 Subject: re-format code --- contrib/uncrustify.cfg | 2 + src/auditor/taler-auditor-exchange.c | 37 +- src/auditor/taler-auditor-httpd.c | 109 +- src/auditor/taler-auditor-httpd_db.c | 37 +- src/auditor/taler-auditor-httpd_db.h | 12 +- .../taler-auditor-httpd_deposit-confirmation.c | 13 +- src/auditor/taler-auditor-httpd_exchanges.c | 8 +- src/auditor/taler-auditor-httpd_mhd.c | 24 +- src/auditor/taler-auditor-httpd_parsing.c | 30 +- src/auditor/taler-auditor-httpd_responses.c | 69 +- src/auditor/taler-auditor-httpd_responses.h | 20 +- src/auditor/taler-auditor-sign.c | 52 +- src/auditor/taler-auditor.c | 357 ++-- src/auditor/taler-wire-auditor.c | 120 +- src/auditordb/auditordb_plugin.c | 2 +- src/auditordb/plugin_auditordb_postgres.c | 551 +++-- src/auditordb/test_auditordb.c | 151 +- src/bank-lib/bank_api_admin.c | 9 +- src/bank-lib/bank_api_common.c | 2 +- src/bank-lib/bank_api_history.c | 18 +- src/bank-lib/bank_api_parse.c | 5 +- src/bank-lib/bank_api_reject.c | 4 +- src/bank-lib/fakebank.c | 57 +- src/bank-lib/fakebank.h | 15 +- src/bank-lib/fakebank_history.c | 55 +- src/bank-lib/taler-bank-transfer.c | 76 +- src/bank-lib/taler-fakebank-run.c | 8 +- src/bank-lib/test_bank_api.c | 38 +- src/bank-lib/test_bank_api_new.c | 80 +- src/bank-lib/test_bank_api_twisted.c | 10 +- src/bank-lib/test_bank_api_with_fakebank.c | 8 +- src/bank-lib/test_bank_api_with_fakebank_new.c | 80 +- src/bank-lib/test_bank_api_with_fakebank_twisted.c | 8 +- src/bank-lib/test_bank_interpreter.c | 77 +- src/bank-lib/test_bank_interpreter.h | 9 +- src/bank-lib/testing_api_cmd_history.c | 162 +- src/bank-lib/testing_api_cmd_reject.c | 10 +- src/bank-lib/testing_api_helpers.c | 78 +- src/benchmark/taler-exchange-benchmark.c | 194 +- src/exchange-tools/taler-exchange-dbinit.c | 28 +- src/exchange-tools/taler-exchange-keycheck.c | 44 +- src/exchange-tools/taler-exchange-keyup.c | 63 +- src/exchange-tools/taler-exchange-wire.c | 14 +- src/exchange-tools/taler-wire.c | 78 +- src/exchange/taler-exchange-aggregator.c | 327 +-- src/exchange/taler-exchange-httpd.c | 448 ++-- src/exchange/taler-exchange-httpd_db.c | 13 +- src/exchange/taler-exchange-httpd_db.h | 19 +- src/exchange/taler-exchange-httpd_deposit.c | 71 +- src/exchange/taler-exchange-httpd_keystate.c | 286 +-- src/exchange/taler-exchange-httpd_keystate.h | 13 +- src/exchange/taler-exchange-httpd_mhd.c | 24 +- src/exchange/taler-exchange-httpd_parsing.c | 34 +- src/exchange/taler-exchange-httpd_payback.c | 64 +- src/exchange/taler-exchange-httpd_refresh_link.c | 25 +- src/exchange/taler-exchange-httpd_refresh_melt.c | 53 +- src/exchange/taler-exchange-httpd_refresh_reveal.c | 97 +- src/exchange/taler-exchange-httpd_refund.c | 102 +- src/exchange/taler-exchange-httpd_refund.h | 8 +- src/exchange/taler-exchange-httpd_reserve_status.c | 33 +- .../taler-exchange-httpd_reserve_withdraw.c | 48 +- src/exchange/taler-exchange-httpd_responses.c | 327 ++- src/exchange/taler-exchange-httpd_responses.h | 21 +- src/exchange/taler-exchange-httpd_test.c | 232 +- src/exchange/taler-exchange-httpd_test.h | 56 +- .../taler-exchange-httpd_track_transaction.c | 113 +- src/exchange/taler-exchange-httpd_track_transfer.c | 118 +- src/exchange/taler-exchange-httpd_validation.c | 2 +- src/exchange/taler-exchange-httpd_wire.c | 20 +- src/exchange/taler-exchange-wirewatch.c | 58 +- src/exchange/test_taler_exchange_aggregator.c | 112 +- src/exchange/test_taler_exchange_wirewatch.c | 63 +- src/exchangedb/exchangedb_accounts.c | 2 +- src/exchangedb/exchangedb_auditorkeys.c | 35 +- src/exchangedb/exchangedb_denomkeys.c | 90 +- src/exchangedb/exchangedb_fees.c | 10 +- src/exchangedb/exchangedb_signkeys.c | 21 +- src/exchangedb/perf_taler_exchangedb.c | 298 +-- src/exchangedb/perf_taler_exchangedb_init.c | 64 +- src/exchangedb/perf_taler_exchangedb_init.h | 33 +- src/exchangedb/perf_taler_exchangedb_interpreter.c | 2215 ++++++++++---------- src/exchangedb/perf_taler_exchangedb_interpreter.h | 420 ++-- src/exchangedb/plugin_exchangedb_common.c | 20 +- src/exchangedb/plugin_exchangedb_postgres.c | 995 +++++---- src/exchangedb/test_exchangedb.c | 280 +-- src/exchangedb/test_exchangedb_auditors.c | 2 +- src/exchangedb/test_exchangedb_denomkeys.c | 24 +- src/exchangedb/test_exchangedb_signkeys.c | 5 +- src/exchangedb/test_perf_taler_exchangedb.c | 101 +- src/include/gauger.h | 150 +- src/include/platform.h | 4 +- src/include/taler_auditor_service.h | 59 +- src/include/taler_auditordb_plugin.h | 267 ++- src/include/taler_bank_service.h | 18 +- src/include/taler_crypto_lib.h | 39 +- src/include/taler_curl_lib.h | 4 +- src/include/taler_error_codes.h | 12 +- src/include/taler_exchange_service.h | 235 ++- src/include/taler_exchangedb_lib.h | 49 +- src/include/taler_exchangedb_plugin.h | 570 +++-- src/include/taler_json_lib.h | 8 +- src/include/taler_pq_lib.h | 3 +- src/include/taler_testing_auditor_lib.h | 30 +- src/include/taler_testing_bank_lib.h | 50 +- src/include/taler_testing_lib.h | 646 +++--- src/include/taler_util.h | 16 +- src/include/taler_util_wallet.h | 16 +- src/include/taler_wire_lib.h | 37 +- src/include/taler_wire_plugin.h | 9 +- src/json/json_helper.c | 4 +- src/json/json_wire.c | 6 +- src/json/test_json.c | 22 +- src/json/test_json_wire.c | 8 +- src/lib/auditor_api_deposit_confirmation.c | 47 +- src/lib/auditor_api_exchanges.c | 9 +- src/lib/auditor_api_handle.c | 38 +- src/lib/exchange_api_common.c | 50 +- src/lib/exchange_api_deposit.c | 53 +- src/lib/exchange_api_handle.c | 275 +-- src/lib/exchange_api_handle.h | 12 +- src/lib/exchange_api_payback.c | 57 +- src/lib/exchange_api_refresh.c | 131 +- src/lib/exchange_api_refresh_link.c | 44 +- src/lib/exchange_api_refund.c | 99 +- src/lib/exchange_api_reserve.c | 160 +- src/lib/exchange_api_track_transaction.c | 46 +- src/lib/exchange_api_track_transfer.c | 49 +- src/lib/exchange_api_wire.c | 12 +- src/lib/teah_common.c | 12 +- src/lib/test_auditor_api.c | 325 +-- src/lib/test_auditor_api_version.c | 28 +- src/lib/test_exchange_api.c | 341 +-- src/lib/test_exchange_api_interpreter_on-off.c | 8 +- src/lib/test_exchange_api_keys_cherry_picking.c | 70 +- src/lib/test_exchange_api_overlapping_keys_bug.c | 2 +- src/lib/test_exchange_api_revocation.c | 48 +- src/lib/test_exchange_api_twisted.c | 176 +- src/lib/testing_api_cmd_bank_check.c | 38 +- src/lib/testing_api_cmd_batch.c | 4 +- src/lib/testing_api_cmd_check_keys.c | 28 +- src/lib/testing_api_cmd_deposit.c | 118 +- src/lib/testing_api_cmd_exec_auditor-sign.c | 32 +- src/lib/testing_api_cmd_exec_keyup.c | 42 +- src/lib/testing_api_cmd_exec_wirewatch.c | 4 +- src/lib/testing_api_cmd_fakebank_transfer.c | 144 +- src/lib/testing_api_cmd_payback.c | 38 +- src/lib/testing_api_cmd_refresh.c | 187 +- src/lib/testing_api_cmd_refund.c | 36 +- src/lib/testing_api_cmd_serialize_keys.c | 32 +- src/lib/testing_api_cmd_signal.c | 2 +- src/lib/testing_api_cmd_sleep.c | 8 +- src/lib/testing_api_cmd_status.c | 28 +- src/lib/testing_api_cmd_track.c | 118 +- src/lib/testing_api_cmd_wire.c | 10 +- src/lib/testing_api_cmd_withdraw.c | 52 +- src/lib/testing_api_helpers.c | 154 +- src/lib/testing_api_loop.c | 99 +- src/lib/testing_api_trait_amount.c | 6 +- src/lib/testing_api_trait_blinding_key.c | 6 +- src/lib/testing_api_trait_cmd.c | 6 +- src/lib/testing_api_trait_coin_priv.c | 6 +- src/lib/testing_api_trait_denom_pub.c | 6 +- src/lib/testing_api_trait_denom_sig.c | 6 +- src/lib/testing_api_trait_exchange_pub.c | 6 +- src/lib/testing_api_trait_exchange_sig.c | 6 +- src/lib/testing_api_trait_fresh_coin.c | 6 +- src/lib/testing_api_trait_json.c | 12 +- src/lib/testing_api_trait_key_peer.c | 12 +- src/lib/testing_api_trait_number.c | 12 +- src/lib/testing_api_trait_process.c | 8 +- src/lib/testing_api_trait_reserve_priv.c | 6 +- src/lib/testing_api_trait_string.c | 36 +- src/lib/testing_api_trait_time.c | 6 +- src/lib/testing_api_trait_wtid.c | 6 +- src/lib/testing_api_traits.c | 2 +- .../testing_auditor_api_cmd_deposit_confirmation.c | 77 +- src/lib/testing_auditor_api_cmd_exchanges.c | 76 +- src/lib/testing_auditor_api_helpers.c | 6 +- src/pq/pq_query_helper.c | 12 +- src/pq/pq_result_helper.c | 12 +- src/pq/test_pq.c | 42 +- src/util/amount.c | 16 +- src/util/crypto.c | 42 +- src/util/crypto_wire.c | 18 +- src/util/test_amount.c | 129 +- src/util/test_crypto.c | 11 +- src/util/test_url.c | 12 +- src/util/util.c | 71 +- src/wire-plugins/plugin_wire_ebics.c | 5 +- src/wire-plugins/plugin_wire_taler-bank.c | 38 +- src/wire-plugins/plugin_wire_template.c | 5 +- src/wire-plugins/test_wire_plugin.c | 23 +- .../test_wire_plugin_transactions_taler-bank.c | 10 +- src/wire/payto.c | 323 ++- src/wire/wire_helper.c | 4 +- 195 files changed, 9079 insertions(+), 7761 deletions(-) diff --git a/contrib/uncrustify.cfg b/contrib/uncrustify.cfg index 5360f1cae..7d392c348 100644 --- a/contrib/uncrustify.cfg +++ b/contrib/uncrustify.cfg @@ -13,6 +13,8 @@ cmd_width=80 cmt_indent_multi=false sp_cmt_cpp_start=add +sp_not=add + ls_for_split_full=true ls_func_split_full=true diff --git a/src/auditor/taler-auditor-exchange.c b/src/auditor/taler-auditor-exchange.c index 04c13fd0d..3cd6edf09 100644 --- a/src/auditor/taler-auditor-exchange.c +++ b/src/auditor/taler-auditor-exchange.c @@ -66,13 +66,14 @@ main (int argc, char *cfgfile = NULL; const struct GNUNET_GETOPT_CommandLineOption options[] = { GNUNET_GETOPT_option_cfgfile (&cfgfile), - GNUNET_GETOPT_option_help ("Add or remove exchange to list of audited exchanges"), + GNUNET_GETOPT_option_help ( + "Add or remove exchange to list of audited exchanges"), GNUNET_GETOPT_option_mandatory - (GNUNET_GETOPT_option_base32_auto ('m', - "exchange-key", - "KEY", - "public key of the exchange (Crockford base32 encoded)", - &master_public_key)), + (GNUNET_GETOPT_option_base32_auto ('m', + "exchange-key", + "KEY", + "public key of the exchange (Crockford base32 encoded)", + &master_public_key)), GNUNET_GETOPT_option_string ('u', "exchange-url", "URL", @@ -108,7 +109,7 @@ main (int argc, cfgfile)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - _("Malformed configuration file `%s', exit ...\n"), + _ ("Malformed configuration file `%s', exit ...\n"), cfgfile); GNUNET_free_non_null (cfgfile); return 1; @@ -120,22 +121,22 @@ main (int argc, if (NULL == exchange_url) { FPRINTF (stderr, - _("Missing either `%s' or `%s'.\n"), - "-u URL", - "--remove"); + _ ("Missing either `%s' or `%s'.\n"), + "-u URL", + "--remove"); return 1; } if ( (0 == strlen (exchange_url)) || - ( (0 != strncasecmp ("http://", - exchange_url, - strlen ("http://"))) && - (0 != strncasecmp ("https://", - exchange_url, - strlen ("https://"))) ) || - ('/' != exchange_url[strlen(exchange_url)-1]) ) + ( (0 != strncasecmp ("http://", + exchange_url, + strlen ("http://"))) && + (0 != strncasecmp ("https://", + exchange_url, + strlen ("https://"))) ) || + ('/' != exchange_url[strlen (exchange_url) - 1]) ) { fprintf (stderr, - "Exchange URL must begin with `http://` or `https://` and end with `/'\n"); + "Exchange URL must begin with `http://` or `https://` and end with `/'\n"); return 1; } } diff --git a/src/auditor/taler-auditor-httpd.c b/src/auditor/taler-auditor-httpd.c index c7c2589c6..967a084ef 100644 --- a/src/auditor/taler-auditor-httpd.c +++ b/src/auditor/taler-auditor-httpd.c @@ -232,10 +232,10 @@ signal_loop (void) break; } if (EINTR == errno) - { - ret = 2; - continue; - } + { + ret = 2; + continue; + } switch (c) { case SIGTERM: @@ -325,7 +325,8 @@ handle_version (struct TAH_RequestHandler *rh, ver = json_pack ("{s:s, s:s, s:o}", "version", AUDITOR_PROTOCOL_VERSION, "currency", currency, - "auditor_public_key", GNUNET_JSON_from_data_auto (&auditor_pub)); + "auditor_public_key", GNUNET_JSON_from_data_auto ( + &auditor_pub)); } if (NULL == ver) { @@ -361,44 +362,42 @@ handle_mhd_request (void *cls, size_t *upload_data_size, void **con_cls) { - static struct TAH_RequestHandler handlers[] = - { - /* Our most popular handler (thus first!), used by merchants to - probabilistically report us their deposit confirmations. */ - { "/deposit-confirmation", MHD_HTTP_METHOD_PUT, "application/json", - NULL, 0, - &TAH_DEPOSIT_CONFIRMATION_handler, MHD_HTTP_OK }, - { "/exchanges", MHD_HTTP_METHOD_GET, "application/json", - NULL, 0, - &TAH_EXCHANGES_handler, MHD_HTTP_OK }, - { "/version", MHD_HTTP_METHOD_GET, "application/json", - NULL, 0, - &handle_version, MHD_HTTP_OK }, - /* Landing page, for now tells humans to go away (FIXME: replace - with auditor's welcome page!) */ - { "/", MHD_HTTP_METHOD_GET, "text/plain", - "Hello, I'm the Taler auditor. This HTTP server is not for humans.\n", 0, - &TAH_MHD_handler_static_response, MHD_HTTP_OK }, - /* /robots.txt: disallow everything */ - { "/robots.txt", MHD_HTTP_METHOD_GET, "text/plain", - "User-agent: *\nDisallow: /\n", 0, - &TAH_MHD_handler_static_response, MHD_HTTP_OK }, - /* AGPL licensing page, redirect to source. As per the AGPL-license, - every deployment is required to offer the user a download of the - source. We make this easy by including a redirect to the source - here. */ - { "/agpl", MHD_HTTP_METHOD_GET, "text/plain", - NULL, 0, - &TAH_MHD_handler_agpl_redirect, MHD_HTTP_FOUND }, - - { NULL, NULL, NULL, NULL, 0, 0 } - }; - static struct TAH_RequestHandler h404 = - { - "", NULL, "text/html", - "404: not found", 0, - &TAH_MHD_handler_static_response, MHD_HTTP_NOT_FOUND - }; + static struct TAH_RequestHandler handlers[] = { + /* Our most popular handler (thus first!), used by merchants to + probabilistically report us their deposit confirmations. */ + { "/deposit-confirmation", MHD_HTTP_METHOD_PUT, "application/json", + NULL, 0, + &TAH_DEPOSIT_CONFIRMATION_handler, MHD_HTTP_OK }, + { "/exchanges", MHD_HTTP_METHOD_GET, "application/json", + NULL, 0, + &TAH_EXCHANGES_handler, MHD_HTTP_OK }, + { "/version", MHD_HTTP_METHOD_GET, "application/json", + NULL, 0, + &handle_version, MHD_HTTP_OK }, + /* Landing page, for now tells humans to go away (FIXME: replace + with auditor's welcome page!) */ + { "/", MHD_HTTP_METHOD_GET, "text/plain", + "Hello, I'm the Taler auditor. This HTTP server is not for humans.\n", 0, + &TAH_MHD_handler_static_response, MHD_HTTP_OK }, + /* /robots.txt: disallow everything */ + { "/robots.txt", MHD_HTTP_METHOD_GET, "text/plain", + "User-agent: *\nDisallow: /\n", 0, + &TAH_MHD_handler_static_response, MHD_HTTP_OK }, + /* AGPL licensing page, redirect to source. As per the AGPL-license, + every deployment is required to offer the user a download of the + source. We make this easy by including a redirect to the source + here. */ + { "/agpl", MHD_HTTP_METHOD_GET, "text/plain", + NULL, 0, + &TAH_MHD_handler_agpl_redirect, MHD_HTTP_FOUND }, + + { NULL, NULL, NULL, NULL, 0, 0 } + }; + static struct TAH_RequestHandler h404 = { + "", NULL, "text/html", + "404: not found", 0, + &TAH_MHD_handler_static_response, MHD_HTTP_NOT_FOUND + }; struct TAH_RequestHandler *rh; GNUNET_log (GNUNET_ERROR_TYPE_INFO, @@ -407,7 +406,7 @@ handle_mhd_request (void *cls, if (0 == strcasecmp (method, MHD_HTTP_METHOD_HEAD)) method = MHD_HTTP_METHOD_GET; /* treat HEAD as GET here, MHD will do the rest */ - for (unsigned int i=0;NULL != handlers[i].url;i++) + for (unsigned int i = 0; NULL != handlers[i].url; i++) { rh = &handlers[i]; if ( (0 == strcasecmp (url, @@ -802,7 +801,8 @@ main (int argc, "SECONDS", "after how long do connections timeout by default (in seconds)", &connection_timeout), - GNUNET_GETOPT_option_help ("HTTP server providing a RESTful API to access a Taler auditor"), + GNUNET_GETOPT_option_help ( + "HTTP server providing a RESTful API to access a Taler auditor"), GNUNET_GETOPT_option_loglevel (&loglev), GNUNET_GETOPT_option_logfile (&logfile), GNUNET_GETOPT_option_version (VERSION "-" VCS_VERSION), @@ -830,7 +830,7 @@ main (int argc, cfgfile)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - _("Malformed configuration file `%s', exit ...\n"), + _ ("Malformed configuration file `%s', exit ...\n"), cfgfile); GNUNET_free_non_null (cfgfile); return 1; @@ -846,9 +846,9 @@ main (int argc, listen_fds = getenv ("LISTEN_FDS"); if ( (NULL != listen_pid) && (NULL != listen_fds) && - (getpid() == strtol (listen_pid, - NULL, - 10)) && + (getpid () == strtol (listen_pid, + NULL, + 10)) && (1 == strtoul (listen_fds, NULL, 10)) ) @@ -885,7 +885,10 @@ main (int argc, } mhd - = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY | MHD_USE_PIPE_FOR_SHUTDOWN | MHD_USE_DEBUG | MHD_USE_DUAL_STACK | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_TCP_FASTOPEN, + = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY | MHD_USE_PIPE_FOR_SHUTDOWN + | MHD_USE_DEBUG | MHD_USE_DUAL_STACK + | MHD_USE_INTERNAL_POLLING_THREAD + | MHD_USE_TCP_FASTOPEN, (-1 == fh) ? serve_port : 0, NULL, NULL, &handle_mhd_request, NULL, @@ -893,7 +896,8 @@ main (int argc, MHD_OPTION_LISTEN_BACKLOG_SIZE, (unsigned int) 1024, MHD_OPTION_LISTEN_SOCKET, fh, MHD_OPTION_EXTERNAL_LOGGER, &handle_mhd_logs, NULL, - MHD_OPTION_NOTIFY_COMPLETED, &handle_mhd_completion_callback, NULL, + MHD_OPTION_NOTIFY_COMPLETED, + &handle_mhd_completion_callback, NULL, MHD_OPTION_CONNECTION_TIMEOUT, connection_timeout, MHD_OPTION_END); if (NULL == mhd) @@ -960,7 +964,8 @@ main (int argc, close it here */ GNUNET_break (0 == close (sock)); while (0 != MHD_get_daemon_info (mhd, - MHD_DAEMON_INFO_CURRENT_CONNECTIONS)->num_connections) + MHD_DAEMON_INFO_CURRENT_CONNECTIONS)-> + num_connections) sleep (1); /* Now we're really done, practice clean shutdown */ MHD_stop_daemon (mhd); diff --git a/src/auditor/taler-auditor-httpd_db.c b/src/auditor/taler-auditor-httpd_db.c index 846829551..e0ab8f2e1 100644 --- a/src/auditor/taler-auditor-httpd_db.c +++ b/src/auditor/taler-auditor-httpd_db.c @@ -51,9 +51,9 @@ int TAH_DB_run_transaction (struct MHD_Connection *connection, const char *name, - int *mhd_ret, - TAH_DB_TransactionCallback cb, - void *cb_cls) + int *mhd_ret, + TAH_DB_TransactionCallback cb, + void *cb_cls) { struct TALER_AUDITORDB_Session *session; @@ -64,46 +64,47 @@ TAH_DB_run_transaction (struct MHD_Connection *connection, GNUNET_break (0); if (NULL != mhd_ret) *mhd_ret = TAH_RESPONSE_reply_internal_db_error (connection, - TALER_EC_DB_SETUP_FAILED); + TALER_EC_DB_SETUP_FAILED); return GNUNET_SYSERR; } // TAH_plugin->preflight (TAH_plugin->cls, session); // FIXME: needed? - for (unsigned int retries = 0;retries < MAX_TRANSACTION_COMMIT_RETRIES; retries++) + for (unsigned int retries = 0; retries < MAX_TRANSACTION_COMMIT_RETRIES; + retries++) { enum GNUNET_DB_QueryStatus qs; if (GNUNET_OK != - TAH_plugin->start (TAH_plugin->cls, - session)) + TAH_plugin->start (TAH_plugin->cls, + session)) { GNUNET_break (0); if (NULL != mhd_ret) - *mhd_ret = TAH_RESPONSE_reply_internal_db_error (connection, - TALER_EC_DB_START_FAILED); + *mhd_ret = TAH_RESPONSE_reply_internal_db_error (connection, + TALER_EC_DB_START_FAILED); return GNUNET_SYSERR; } qs = cb (cb_cls, - connection, - session, - mhd_ret); + connection, + session, + mhd_ret); if (0 > qs) TAH_plugin->rollback (TAH_plugin->cls, - session); + session); if (GNUNET_DB_STATUS_HARD_ERROR == qs) return GNUNET_SYSERR; if (0 <= qs) qs = TAH_plugin->commit (TAH_plugin->cls, - session); + session); if (GNUNET_DB_STATUS_HARD_ERROR == qs) { if (NULL != mhd_ret) - *mhd_ret = TAH_RESPONSE_reply_commit_error (connection, - TALER_EC_DB_COMMIT_FAILED_HARD); + *mhd_ret = TAH_RESPONSE_reply_commit_error (connection, + TALER_EC_DB_COMMIT_FAILED_HARD); return GNUNET_SYSERR; } /* make sure callback did not violate invariants! */ GNUNET_assert ( (NULL == mhd_ret) || - (-1 == *mhd_ret) ); + (-1 == *mhd_ret) ); if (0 <= qs) return GNUNET_OK; } @@ -112,7 +113,7 @@ TAH_DB_run_transaction (struct MHD_Connection *connection, MAX_TRANSACTION_COMMIT_RETRIES); if (NULL != mhd_ret) *mhd_ret = TAH_RESPONSE_reply_commit_error (connection, - TALER_EC_DB_COMMIT_FAILED_ON_RETRY); + TALER_EC_DB_COMMIT_FAILED_ON_RETRY); return GNUNET_SYSERR; } diff --git a/src/auditor/taler-auditor-httpd_db.h b/src/auditor/taler-auditor-httpd_db.h index 9aad86c12..1f702c818 100644 --- a/src/auditor/taler-auditor-httpd_db.h +++ b/src/auditor/taler-auditor-httpd_db.h @@ -41,9 +41,9 @@ */ typedef enum GNUNET_DB_QueryStatus (*TAH_DB_TransactionCallback)(void *cls, - struct MHD_Connection *connection, - struct TALER_AUDITORDB_Session *session, - int *mhd_ret); + struct MHD_Connection *connection, + struct TALER_AUDITORDB_Session *session, + int *mhd_ret); /** @@ -63,9 +63,9 @@ typedef enum GNUNET_DB_QueryStatus int TAH_DB_run_transaction (struct MHD_Connection *connection, const char *name, - int *mhd_ret, - TAH_DB_TransactionCallback cb, - void *cb_cls); + int *mhd_ret, + TAH_DB_TransactionCallback cb, + void *cb_cls); #endif diff --git a/src/auditor/taler-auditor-httpd_deposit-confirmation.c b/src/auditor/taler-auditor-httpd_deposit-confirmation.c index af86378cd..2b73a910a 100644 --- a/src/auditor/taler-auditor-httpd_deposit-confirmation.c +++ b/src/auditor/taler-auditor-httpd_deposit-confirmation.c @@ -75,7 +75,7 @@ store_exchange_signing_key_transaction (void *cls, { TALER_LOG_WARNING ("Failed to store exchange signing key in database\n"); *mhd_ret = TAH_RESPONSE_reply_internal_db_error (connection, - TALER_EC_AUDITOR_EXCHANGE_STORE_DB_ERROR); + TALER_EC_AUDITOR_EXCHANGE_STORE_DB_ERROR); } return qs; } @@ -109,9 +109,10 @@ deposit_confirmation_transaction (void *cls, dc); if (GNUNET_DB_STATUS_HARD_ERROR == qs) { - TALER_LOG_WARNING ("Failed to store /deposit-confirmation information in database\n"); + TALER_LOG_WARNING ( + "Failed to store /deposit-confirmation information in database\n"); *mhd_ret = TAH_RESPONSE_reply_internal_db_error (connection, - TALER_EC_DEPOSIT_CONFIRMATION_STORE_DB_ERROR); + TALER_EC_DEPOSIT_CONFIRMATION_STORE_DB_ERROR); } return qs; } @@ -130,8 +131,10 @@ deposit_confirmation_transaction (void *cls, */ static int verify_and_execute_deposit_confirmation (struct MHD_Connection *connection, - const struct TALER_AUDITORDB_DepositConfirmation *dc, - const struct TALER_AUDITORDB_ExchangeSigningKey *es) + const struct + TALER_AUDITORDB_DepositConfirmation *dc, + const struct + TALER_AUDITORDB_ExchangeSigningKey *es) { struct TALER_ExchangeSigningKeyValidityPS skv; struct TALER_DepositConfirmationPS dcs; diff --git a/src/auditor/taler-auditor-httpd_exchanges.c b/src/auditor/taler-auditor-httpd_exchanges.c index 866e4c7be..881c45a23 100644 --- a/src/auditor/taler-auditor-httpd_exchanges.c +++ b/src/auditor/taler-auditor-httpd_exchanges.c @@ -109,7 +109,7 @@ list_exchanges (void *cls, { TALER_LOG_WARNING ("Failed to handle /exchanges in database\n"); *mhd_ret = TAH_RESPONSE_reply_internal_db_error (connection, - TALER_EC_LIST_EXCHANGES_DB_ERROR); + TALER_EC_LIST_EXCHANGES_DB_ERROR); } return qs; } @@ -139,9 +139,9 @@ TAH_EXCHANGES_handler (struct TAH_RequestHandler *rh, if (GNUNET_OK != TAH_DB_run_transaction (connection, "list exchanges", - &mhd_ret, - &list_exchanges, - (void *) ja)) + &mhd_ret, + &list_exchanges, + (void *) ja)) return mhd_ret; return reply_exchanges_success (connection, ja); diff --git a/src/auditor/taler-auditor-httpd_mhd.c b/src/auditor/taler-auditor-httpd_mhd.c index b8fc65afd..5f13691f5 100644 --- a/src/auditor/taler-auditor-httpd_mhd.c +++ b/src/auditor/taler-auditor-httpd_mhd.c @@ -45,10 +45,10 @@ */ int TAH_MHD_handler_static_response (struct TAH_RequestHandler *rh, - struct MHD_Connection *connection, - void **connection_cls, - const char *upload_data, - size_t *upload_data_size) + struct MHD_Connection *connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size) { struct MHD_Response *response; int ret; @@ -142,16 +142,16 @@ TAH_MHD_handler_agpl_redirect (struct TAH_RequestHandler *rh, */ int TAH_MHD_handler_send_json_pack_error (struct TAH_RequestHandler *rh, - struct MHD_Connection *connection, - void **connection_cls, - const char *upload_data, - size_t *upload_data_size) + struct MHD_Connection *connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size) { return TAH_RESPONSE_reply_json_pack (connection, - rh->response_code, - "{s:s}", - "error", - rh->data); + rh->response_code, + "{s:s}", + "error", + rh->data); } diff --git a/src/auditor/taler-auditor-httpd_parsing.c b/src/auditor/taler-auditor-httpd_parsing.c index 36ae4a166..bac338cc0 100644 --- a/src/auditor/taler-auditor-httpd_parsing.c +++ b/src/auditor/taler-auditor-httpd_parsing.c @@ -33,7 +33,7 @@ /** * Maximum POST request size. */ -#define REQUEST_BUFFER_MAX (1024*1024) +#define REQUEST_BUFFER_MAX (1024 * 1024) @@ -82,17 +82,17 @@ TAH_PARSE_post_json (struct MHD_Connection *connection, TAH_RESPONSE_reply_internal_error (connection, TALER_EC_PARSER_OUT_OF_MEMORY, "out of memory")) - ? GNUNET_SYSERR : GNUNET_NO; + ? GNUNET_SYSERR : GNUNET_NO; case GNUNET_JSON_PR_CONTINUE: return GNUNET_YES; case GNUNET_JSON_PR_REQUEST_TOO_LARGE: return (MHD_NO == TAH_RESPONSE_reply_request_too_large (connection)) - ? GNUNET_SYSERR : GNUNET_NO; + ? GNUNET_SYSERR : GNUNET_NO; case GNUNET_JSON_PR_JSON_INVALID: return (MHD_YES == TAH_RESPONSE_reply_invalid_json (connection)) - ? GNUNET_NO : GNUNET_SYSERR; + ? GNUNET_NO : GNUNET_SYSERR; case GNUNET_JSON_PR_SUCCESS: GNUNET_break (NULL != *json); return GNUNET_YES; @@ -147,9 +147,9 @@ TAH_PARSE_mhd_request_arg_data (struct MHD_Connection *connection, { return (MHD_NO == TAH_RESPONSE_reply_arg_missing (connection, - TALER_EC_PARAMETER_MISSING, - param_name)) - ? GNUNET_SYSERR : GNUNET_NO; + TALER_EC_PARAMETER_MISSING, + param_name)) + ? GNUNET_SYSERR : GNUNET_NO; } if (GNUNET_OK != GNUNET_STRINGS_string_to_data (str, @@ -158,9 +158,9 @@ TAH_PARSE_mhd_request_arg_data (struct MHD_Connection *connection, out_size)) return (MHD_NO == TAH_RESPONSE_reply_arg_invalid (connection, - TALER_EC_PARAMETER_MALFORMED, - param_name)) - ? GNUNET_SYSERR : GNUNET_NO; + TALER_EC_PARAMETER_MALFORMED, + param_name)) + ? GNUNET_SYSERR : GNUNET_NO; return GNUNET_OK; } @@ -201,10 +201,12 @@ TAH_PARSE_json_data (struct MHD_Connection *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, + "code", + (json_int_t) + TALER_EC_JSON_INVALID_WITH_DETAILS, "field", error_json_name, "line", (json_int_t) error_line)) - ? GNUNET_NO : GNUNET_SYSERR; + ? GNUNET_NO : GNUNET_SYSERR; return ret; } return GNUNET_YES; @@ -255,7 +257,7 @@ TAH_PARSE_json_array (struct MHD_Connection *connection, "{s:s, s:I}", "error", "parse error", "dimension", dim)) - ? GNUNET_NO : GNUNET_SYSERR; + ? GNUNET_NO : GNUNET_SYSERR; return ret; } ret = GNUNET_JSON_parse (root, @@ -273,7 +275,7 @@ TAH_PARSE_json_array (struct MHD_Connection *connection, "error", "parse error", "field", error_json_name, "line", (json_int_t) error_line)) - ? GNUNET_NO : GNUNET_SYSERR; + ? GNUNET_NO : GNUNET_SYSERR; return ret; } return GNUNET_YES; diff --git a/src/auditor/taler-auditor-httpd_responses.c b/src/auditor/taler-auditor-httpd_responses.c index 045a77772..4c7b429e3 100644 --- a/src/auditor/taler-auditor-httpd_responses.c +++ b/src/auditor/taler-auditor-httpd_responses.c @@ -65,22 +65,22 @@ TAH_RESPONSE_can_compress (struct MHD_Connection *connection) const char *de; ae = MHD_lookup_connection_value (connection, - MHD_HEADER_KIND, - MHD_HTTP_HEADER_ACCEPT_ENCODING); + MHD_HEADER_KIND, + MHD_HTTP_HEADER_ACCEPT_ENCODING); if (NULL == ae) return MHD_NO; if (0 == strcmp (ae, "*")) return MHD_YES; de = strstr (ae, - "deflate"); + "deflate"); if (NULL == de) return MHD_NO; if ( ( (de == ae) || - (de[-1] == ',') || - (de[-1] == ' ') ) && + (de[-1] == ',') || + (de[-1] == ' ') ) && ( (de[strlen ("deflate")] == '\0') || - (de[strlen ("deflate")] == ',') || + (de[strlen ("deflate")] == ',') || (de[strlen ("deflate")] == ';') ) ) return MHD_YES; return MHD_NO; @@ -96,7 +96,7 @@ TAH_RESPONSE_can_compress (struct MHD_Connection *connection) */ int TAH_RESPONSE_body_compress (void **buf, - size_t *buf_size) + size_t *buf_size) { Bytef *cbuf; uLongf cbuf_size; @@ -107,9 +107,9 @@ TAH_RESPONSE_body_compress (void **buf, if (NULL == cbuf) return MHD_NO; ret = compress (cbuf, - &cbuf_size, - (const Bytef *) *buf, - *buf_size); + &cbuf_size, + (const Bytef *) *buf, + *buf_size); if ( (Z_OK != ret) || (cbuf_size >= *buf_size) ) { @@ -144,7 +144,7 @@ TAH_RESPONSE_reply_json (struct MHD_Connection *connection, int comp; json_str = json_dumps (json, - JSON_INDENT(2)); + JSON_INDENT (2)); if (NULL == json_str) { /** @@ -163,7 +163,7 @@ TAH_RESPONSE_reply_json (struct MHD_Connection *connection, if (MHD_YES == TAH_RESPONSE_can_compress (connection)) comp = TAH_RESPONSE_body_compress (&json_str, - &json_len); + &json_len); resp = MHD_create_response_from_buffer (json_len, json_str, MHD_RESPMEM_MUST_FREE); @@ -181,9 +181,9 @@ TAH_RESPONSE_reply_json (struct MHD_Connection *connection, { /* Need to indicate to client that body is compressed */ if (MHD_NO == - MHD_add_response_header (resp, - MHD_HTTP_HEADER_CONTENT_ENCODING, - "deflate")) + MHD_add_response_header (resp, + MHD_HTTP_HEADER_CONTENT_ENCODING, + "deflate")) { GNUNET_break (0); MHD_destroy_response (resp); @@ -249,14 +249,14 @@ TAH_RESPONSE_reply_json_pack (struct MHD_Connection *connection, */ int TAH_RESPONSE_reply_arg_invalid (struct MHD_Connection *connection, - enum TALER_ErrorCode ec, + enum TALER_ErrorCode ec, const char *param_name) { return TAH_RESPONSE_reply_json_pack (connection, MHD_HTTP_BAD_REQUEST, "{s:s, s:I, s:s}", "error", "invalid parameter", - "code", (json_int_t) ec, + "code", (json_int_t) ec, "parameter", param_name); } @@ -273,14 +273,14 @@ TAH_RESPONSE_reply_arg_invalid (struct MHD_Connection *connection, */ int TAH_RESPONSE_reply_arg_unknown (struct MHD_Connection *connection, - enum TALER_ErrorCode ec, + enum TALER_ErrorCode ec, const char *param_name) { return TAH_RESPONSE_reply_json_pack (connection, MHD_HTTP_NOT_FOUND, "{s:s, s:I, s:s}", "error", "unknown entity referenced", - "code", (json_int_t) ec, + "code", (json_int_t) ec, "parameter", param_name); } @@ -295,14 +295,14 @@ TAH_RESPONSE_reply_arg_unknown (struct MHD_Connection *connection, */ int TAH_RESPONSE_reply_signature_invalid (struct MHD_Connection *connection, - enum TALER_ErrorCode ec, + enum TALER_ErrorCode ec, const char *param_name) { return TAH_RESPONSE_reply_json_pack (connection, MHD_HTTP_UNAUTHORIZED, "{s:s, s:I, s:s}", "error", "invalid signature", - "code", (json_int_t) ec, + "code", (json_int_t) ec, "parameter", param_name); } @@ -317,14 +317,14 @@ TAH_RESPONSE_reply_signature_invalid (struct MHD_Connection *connection, */ int TAH_RESPONSE_reply_arg_missing (struct MHD_Connection *connection, - enum TALER_ErrorCode ec, + enum TALER_ErrorCode ec, const char *param_name) { return TAH_RESPONSE_reply_json_pack (connection, MHD_HTTP_BAD_REQUEST, "{s:s, s:I, s:s}", "error", "missing parameter", - "code", (json_int_t) ec, + "code", (json_int_t) ec, "parameter", param_name); } @@ -339,14 +339,14 @@ TAH_RESPONSE_reply_arg_missing (struct MHD_Connection *connection, */ int TAH_RESPONSE_reply_permission_denied (struct MHD_Connection *connection, - enum TALER_ErrorCode ec, + enum TALER_ErrorCode ec, const char *hint) { return TAH_RESPONSE_reply_json_pack (connection, MHD_HTTP_FORBIDDEN, "{s:s, s:I, s:s}", "error", "permission denied", - "code", (json_int_t) ec, + "code", (json_int_t) ec, "hint", hint); } @@ -361,14 +361,14 @@ TAH_RESPONSE_reply_permission_denied (struct MHD_Connection *connection, */ int TAH_RESPONSE_reply_internal_error (struct MHD_Connection *connection, - enum TALER_ErrorCode ec, + enum TALER_ErrorCode ec, const char *hint) { return TAH_RESPONSE_reply_json_pack (connection, MHD_HTTP_INTERNAL_SERVER_ERROR, "{s:s, s:I, s:s}", "error", "internal error", - "code", (json_int_t) ec, + "code", (json_int_t) ec, "hint", hint); } @@ -383,14 +383,14 @@ TAH_RESPONSE_reply_internal_error (struct MHD_Connection *connection, */ int TAH_RESPONSE_reply_external_error (struct MHD_Connection *connection, - enum TALER_ErrorCode ec, + enum TALER_ErrorCode ec, const char *hint) { return TAH_RESPONSE_reply_json_pack (connection, MHD_HTTP_BAD_REQUEST, "{s:s, s:I, s:s}", "error", "client error", - "code", (json_int_t) ec, + "code", (json_int_t) ec, "hint", hint); } @@ -405,13 +405,13 @@ TAH_RESPONSE_reply_external_error (struct MHD_Connection *connection, */ int TAH_RESPONSE_reply_commit_error (struct MHD_Connection *connection, - enum TALER_ErrorCode ec) + enum TALER_ErrorCode ec) { return TAH_RESPONSE_reply_json_pack (connection, MHD_HTTP_INTERNAL_SERVER_ERROR, "{s:s, s:I}", "error", "commit failure", - "code", (json_int_t) ec); + "code", (json_int_t) ec); } @@ -425,10 +425,10 @@ TAH_RESPONSE_reply_commit_error (struct MHD_Connection *connection, */ int TAH_RESPONSE_reply_internal_db_error (struct MHD_Connection *connection, - enum TALER_ErrorCode ec) + enum TALER_ErrorCode ec) { return TAH_RESPONSE_reply_internal_error (connection, - ec, + ec, "Failure in database interaction"); } @@ -472,7 +472,8 @@ TAH_RESPONSE_reply_invalid_json (struct MHD_Connection *connection) MHD_HTTP_BAD_REQUEST, "{s:s, s:I}", "error", "invalid json", - "code", (json_int_t) TALER_EC_JSON_INVALID); + "code", + (json_int_t) TALER_EC_JSON_INVALID); } diff --git a/src/auditor/taler-auditor-httpd_responses.h b/src/auditor/taler-auditor-httpd_responses.h index 95e6183ef..1cb5faa82 100644 --- a/src/auditor/taler-auditor-httpd_responses.h +++ b/src/auditor/taler-auditor-httpd_responses.h @@ -53,7 +53,7 @@ TAH_RESPONSE_add_global_headers (struct MHD_Response *response); */ int TAH_RESPONSE_body_compress (void **buf, - size_t *buf_size); + size_t *buf_size); /** @@ -107,7 +107,7 @@ TAH_RESPONSE_reply_json_pack (struct MHD_Connection *connection, */ int TAH_RESPONSE_reply_signature_invalid (struct MHD_Connection *connection, - enum TALER_ErrorCode ec, + enum TALER_ErrorCode ec, const char *param_name); @@ -121,7 +121,7 @@ TAH_RESPONSE_reply_signature_invalid (struct MHD_Connection *connection, */ int TAH_RESPONSE_reply_arg_invalid (struct MHD_Connection *connection, - enum TALER_ErrorCode ec, + enum TALER_ErrorCode ec, const char *param_name); @@ -137,7 +137,7 @@ TAH_RESPONSE_reply_arg_invalid (struct MHD_Connection *connection, */ int TAH_RESPONSE_reply_arg_unknown (struct MHD_Connection *connection, - enum TALER_ErrorCode ec, + enum TALER_ErrorCode ec, const char *param_name); @@ -151,7 +151,7 @@ TAH_RESPONSE_reply_arg_unknown (struct MHD_Connection *connection, */ int TAH_RESPONSE_reply_arg_missing (struct MHD_Connection *connection, - enum TALER_ErrorCode ec, + enum TALER_ErrorCode ec, const char *param_name); @@ -165,7 +165,7 @@ TAH_RESPONSE_reply_arg_missing (struct MHD_Connection *connection, */ int TAH_RESPONSE_reply_permission_denied (struct MHD_Connection *connection, - enum TALER_ErrorCode ec, + enum TALER_ErrorCode ec, const char *hint); @@ -179,7 +179,7 @@ TAH_RESPONSE_reply_permission_denied (struct MHD_Connection *connection, */ int TAH_RESPONSE_reply_internal_error (struct MHD_Connection *connection, - enum TALER_ErrorCode ec, + enum TALER_ErrorCode ec, const char *hint); @@ -193,7 +193,7 @@ TAH_RESPONSE_reply_internal_error (struct MHD_Connection *connection, */ int TAH_RESPONSE_reply_external_error (struct MHD_Connection *connection, - enum TALER_ErrorCode ec, + enum TALER_ErrorCode ec, const char *hint); @@ -207,7 +207,7 @@ TAH_RESPONSE_reply_external_error (struct MHD_Connection *connection, */ int TAH_RESPONSE_reply_commit_error (struct MHD_Connection *connection, - enum TALER_ErrorCode ec); + enum TALER_ErrorCode ec); /** * Send a response indicating a failure to talk to the Auditor's @@ -219,7 +219,7 @@ TAH_RESPONSE_reply_commit_error (struct MHD_Connection *connection, */ int TAH_RESPONSE_reply_internal_db_error (struct MHD_Connection *connection, - enum TALER_ErrorCode ec); + enum TALER_ErrorCode ec); /** diff --git a/src/auditor/taler-auditor-sign.c b/src/auditor/taler-auditor-sign.c index 0636900ff..1bd7e908e 100644 --- a/src/auditor/taler-auditor-sign.c +++ b/src/auditor/taler-auditor-sign.c @@ -86,14 +86,14 @@ print_dk (const struct TALER_DenominationKeyValidityPS *dk) "Value: %s\n", s = TALER_amount_to_string (&a)); GNUNET_free (s); - TALER_amount_ntoh (&a, - &dk->fee_withdraw); + TALER_amount_ntoh (&a, + &dk->fee_withdraw); fprintf (stdout, "Withdraw fee: %s\n", s = TALER_amount_to_string (&a)); GNUNET_free (s); - TALER_amount_ntoh (&a, - &dk->fee_deposit); + TALER_amount_ntoh (&a, + &dk->fee_deposit); fprintf (stdout, "Deposit fee: %s\n", s = TALER_amount_to_string (&a)); @@ -113,16 +113,20 @@ print_dk (const struct TALER_DenominationKeyValidityPS *dk) fprintf (stdout, "Validity start time: %s\n", - GNUNET_STRINGS_absolute_time_to_string (GNUNET_TIME_absolute_ntoh (dk->start))); + GNUNET_STRINGS_absolute_time_to_string (GNUNET_TIME_absolute_ntoh ( + dk->start))); fprintf (stdout, "Withdraw end time: %s\n", - GNUNET_STRINGS_absolute_time_to_string (GNUNET_TIME_absolute_ntoh (dk->expire_withdraw))); + GNUNET_STRINGS_absolute_time_to_string (GNUNET_TIME_absolute_ntoh ( + dk->expire_withdraw))); fprintf (stdout, "Deposit end time: %s\n", - GNUNET_STRINGS_absolute_time_to_string (GNUNET_TIME_absolute_ntoh (dk->expire_deposit))); + GNUNET_STRINGS_absolute_time_to_string (GNUNET_TIME_absolute_ntoh ( + dk->expire_deposit))); fprintf (stdout, "Legal dispute end time: %s\n", - GNUNET_STRINGS_absolute_time_to_string (GNUNET_TIME_absolute_ntoh (dk->expire_legal))); + GNUNET_STRINGS_absolute_time_to_string (GNUNET_TIME_absolute_ntoh ( + dk->expire_legal))); fprintf (stdout, "\n"); @@ -153,22 +157,22 @@ main (int argc, GNUNET_GETOPT_option_cfgfile (&cfgfile), GNUNET_GETOPT_option_help ("Sign denomination keys of an exchange"), GNUNET_GETOPT_option_mandatory - (GNUNET_GETOPT_option_base32_auto ('m', - "exchange-key", - "KEY", - "public key of the exchange (Crockford base32 encoded)", - &master_public_key)), + (GNUNET_GETOPT_option_base32_auto ('m', + "exchange-key", + "KEY", + "public key of the exchange (Crockford base32 encoded)", + &master_public_key)), GNUNET_GETOPT_option_string ('u', "auditor-url", "URL", "URL of the auditor (informative link for the user)", &auditor_url), GNUNET_GETOPT_option_mandatory - (GNUNET_GETOPT_option_filename ('r', - "exchange-request", - "FILENAME", - "set of keys the exchange requested the auditor to sign", - &exchange_request_file)), + (GNUNET_GETOPT_option_filename ('r', + "exchange-request", + "FILENAME", + "set of keys the exchange requested the auditor to sign", + &exchange_request_file)), GNUNET_GETOPT_option_filename ('o', "output", "FILENAME", @@ -203,7 +207,7 @@ main (int argc, cfgfile)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - _("Malformed configuration file `%s', exit ...\n"), + _ ("Malformed configuration file `%s', exit ...\n"), cfgfile); GNUNET_free_non_null (cfgfile); return 1; @@ -325,7 +329,7 @@ main (int argc, return 1; } GNUNET_DISK_file_close (fh); - for (unsigned int i=0;iinsert_denomination_info (adb->cls, - session, - dk); + session, + dk); if (0 > qs) { fprintf (stderr, diff --git a/src/auditor/taler-auditor.c b/src/auditor/taler-auditor.c index dbc337948..536a5cabe 100644 --- a/src/auditor/taler-auditor.c +++ b/src/auditor/taler-auditor.c @@ -342,12 +342,12 @@ static struct TALER_Amount total_refresh_hanging; */ static void report (json_t *array, - json_t *object) + json_t *object) { GNUNET_assert (NULL != object); GNUNET_assert (0 == - json_array_append_new (array, - object)); + json_array_append_new (array, + object)); } @@ -363,21 +363,25 @@ report (json_t *array, * @param risk maximum risk that might have just become real (coins created by this @a dki) */ static void -report_emergency_by_amount (const struct TALER_EXCHANGEDB_DenominationKeyInformationP *dki, +report_emergency_by_amount (const struct + TALER_EXCHANGEDB_DenominationKeyInformationP *dki, const struct TALER_Amount *risk) { report (report_emergencies, - json_pack ("{s:o, s:o, s:s, s:s, s:o}", - "denompub_hash", - GNUNET_JSON_from_data_auto (&dki->properties.denom_hash), - "denom_risk", - TALER_JSON_from_amount (risk), - "start", - GNUNET_STRINGS_absolute_time_to_string (GNUNET_TIME_absolute_ntoh (dki->properties.start)), - "deposit_end", - GNUNET_STRINGS_absolute_time_to_string (GNUNET_TIME_absolute_ntoh (dki->properties.expire_deposit)), - "value", - TALER_JSON_from_amount_nbo (&dki->properties.value))); + json_pack ("{s:o, s:o, s:s, s:s, s:o}", + "denompub_hash", + GNUNET_JSON_from_data_auto (&dki->properties.denom_hash), + "denom_risk", + TALER_JSON_from_amount (risk), + "start", + GNUNET_STRINGS_absolute_time_to_string ( + GNUNET_TIME_absolute_ntoh (dki->properties.start)), + "deposit_end", + GNUNET_STRINGS_absolute_time_to_string ( + GNUNET_TIME_absolute_ntoh ( + dki->properties.expire_deposit)), + "value", + TALER_JSON_from_amount_nbo (&dki->properties.value))); GNUNET_assert (GNUNET_OK == TALER_amount_add (&reported_emergency_sum, &reported_emergency_sum, @@ -400,27 +404,31 @@ report_emergency_by_amount (const struct TALER_EXCHANGEDB_DenominationKeyInforma * @param risk amount that is at risk */ static void -report_emergency_by_count (const struct TALER_EXCHANGEDB_DenominationKeyInformationP *dki, +report_emergency_by_count (const struct + TALER_EXCHANGEDB_DenominationKeyInformationP *dki, uint64_t num_issued, uint64_t num_known, const struct TALER_Amount *risk) { report (report_emergencies, - json_pack ("{s:o, s:I, s:I, s:o, s:s, s:s, s:o}", - "denompub_hash", - GNUNET_JSON_from_data_auto (&dki->properties.denom_hash), - "num_issued", - (json_int_t) num_issued, - "num_known", - (json_int_t) num_known, - "denom_risk", - TALER_JSON_from_amount (risk), - "start", - GNUNET_STRINGS_absolute_time_to_string (GNUNET_TIME_absolute_ntoh (dki->properties.start)), - "deposit_end", - GNUNET_STRINGS_absolute_time_to_string (GNUNET_TIME_absolute_ntoh (dki->properties.expire_deposit)), - "value", - TALER_JSON_from_amount_nbo (&dki->properties.value))); + json_pack ("{s:o, s:I, s:I, s:o, s:s, s:s, s:o}", + "denompub_hash", + GNUNET_JSON_from_data_auto (&dki->properties.denom_hash), + "num_issued", + (json_int_t) num_issued, + "num_known", + (json_int_t) num_known, + "denom_risk", + TALER_JSON_from_amount (risk), + "start", + GNUNET_STRINGS_absolute_time_to_string ( + GNUNET_TIME_absolute_ntoh (dki->properties.start)), + "deposit_end", + GNUNET_STRINGS_absolute_time_to_string ( + GNUNET_TIME_absolute_ntoh ( + dki->properties.expire_deposit)), + "value", + TALER_JSON_from_amount_nbo (&dki->properties.value))); GNUNET_assert (GNUNET_OK == TALER_amount_add (&reported_emergency_sum, &reported_emergency_sum, @@ -463,7 +471,7 @@ report_amount_arithmetic_inconsistency (const char *operation, else { /* auditor < exchange */ - profitable = - profitable; + profitable = -profitable; GNUNET_break (GNUNET_OK == TALER_amount_subtract (&delta, auditor, @@ -479,8 +487,8 @@ report_amount_arithmetic_inconsistency (const char *operation, if (0 != profitable) { target = (1 == profitable) - ? &total_arithmetic_delta_plus - : &total_arithmetic_delta_minus; + ? &total_arithmetic_delta_plus + : &total_arithmetic_delta_minus; GNUNET_break (GNUNET_OK == TALER_amount_add (target, target, @@ -504,7 +512,8 @@ report_amount_arithmetic_inconsistency (const char *operation, */ static void report_coin_arithmetic_inconsistency (const char *operation, - const struct TALER_CoinSpendPublicKeyP *coin_pub, + const struct + TALER_CoinSpendPublicKeyP *coin_pub, const struct TALER_Amount *exchange, const struct TALER_Amount *auditor, int profitable) @@ -524,7 +533,7 @@ report_coin_arithmetic_inconsistency (const char *operation, else { /* auditor < exchange */ - profitable = - profitable; + profitable = -profitable; GNUNET_break (GNUNET_OK == TALER_amount_subtract (&delta, auditor, @@ -540,8 +549,8 @@ report_coin_arithmetic_inconsistency (const char *operation, if (0 != profitable) { target = (1 == profitable) - ? &total_coin_delta_plus - : &total_coin_delta_minus; + ? &total_coin_delta_plus + : &total_coin_delta_minus; GNUNET_break (GNUNET_OK == TALER_amount_add (target, target, @@ -563,10 +572,10 @@ report_row_inconsistency (const char *table, const char *diagnostic) { report (report_row_inconsistencies, - json_pack ("{s:s, s:I, s:s}", - "table", table, - "row", (json_int_t) rowid, - "diagnostic", diagnostic)); + json_pack ("{s:s, s:I, s:s}", + "table", table, + "row", (json_int_t) rowid, + "diagnostic", diagnostic)); } @@ -588,7 +597,9 @@ static struct GNUNET_CONTAINER_MultiHashMap *denominations; */ static enum GNUNET_DB_QueryStatus get_denomination_info_by_hash (const struct GNUNET_HashCode *dh, - const struct TALER_EXCHANGEDB_DenominationKeyInformationP **dki) + const struct + TALER_EXCHANGEDB_DenominationKeyInformationP ** + dki) { struct TALER_EXCHANGEDB_DenominationKeyInformationP *dkip; enum GNUNET_DB_QueryStatus qs; @@ -646,7 +657,8 @@ get_denomination_info_by_hash (const struct GNUNET_HashCode *dh, */ static enum GNUNET_DB_QueryStatus get_denomination_info (const struct TALER_DenominationPublicKey *denom_pub, - const struct TALER_EXCHANGEDB_DenominationKeyInformationP **dki, + const struct + TALER_EXCHANGEDB_DenominationKeyInformationP **dki, struct GNUNET_HashCode *dh) { struct GNUNET_HashCode hc; @@ -997,9 +1009,11 @@ handle_reserve_out (void *cls, report (denomination_key_validity_withdraw_inconsistencies, json_pack ("{s:I, s:s, s:o, s:o}", "row", (json_int_t) rowid, - "execution_date", GNUNET_STRINGS_absolute_time_to_string (execution_date), + "execution_date", + GNUNET_STRINGS_absolute_time_to_string (execution_date), "reserve_pub", GNUNET_JSON_from_data_auto (reserve_pub), - "denompub_h", GNUNET_JSON_from_data_auto (&wsrd.h_denomination_pub))); + "denompub_h", GNUNET_JSON_from_data_auto ( + &wsrd.h_denomination_pub))); } /* check reserve_sig */ @@ -1106,7 +1120,8 @@ handle_payback_by_reserve (void *cls, const struct TALER_CoinPublicInfo *coin, const struct TALER_DenominationPublicKey *denom_pub, const struct TALER_CoinSpendSignatureP *coin_sig, - const struct TALER_DenominationBlindingKeyP *coin_blind) + const struct + TALER_DenominationBlindingKeyP *coin_blind) { struct ReserveContext *rc = cls; struct GNUNET_HashCode key; @@ -1138,7 +1153,8 @@ handle_payback_by_reserve (void *cls, "operation", "payback", "row", (json_int_t) rowid, "loss", TALER_JSON_from_amount (amount), - "key_pub", GNUNET_JSON_from_data_auto (&coin->coin_pub))); + "key_pub", GNUNET_JSON_from_data_auto ( + &coin->coin_pub))); GNUNET_break (GNUNET_OK == TALER_amount_add (&total_bad_sig_loss, &total_bad_sig_loss, @@ -1175,14 +1191,16 @@ handle_payback_by_reserve (void *cls, /* verify msig */ struct TALER_MasterDenominationKeyRevocationPS kr; - kr.purpose.purpose = htonl (TALER_SIGNATURE_MASTER_DENOMINATION_KEY_REVOKED); + kr.purpose.purpose = htonl ( + TALER_SIGNATURE_MASTER_DENOMINATION_KEY_REVOKED); kr.purpose.size = htonl (sizeof (kr)); kr.h_denom_pub = pr.h_denom_pub; if (GNUNET_OK != - GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_MASTER_DENOMINATION_KEY_REVOKED, - &kr.purpose, - &msig.eddsa_signature, - &master_pub.eddsa_pub)) + GNUNET_CRYPTO_eddsa_verify ( + TALER_SIGNATURE_MASTER_DENOMINATION_KEY_REVOKED, + &kr.purpose, + &msig.eddsa_signature, + &master_pub.eddsa_pub)) { rev = "master signature invalid"; } @@ -1287,7 +1305,8 @@ handle_reserve_closed (void *cls, const struct TALER_Amount *closing_fee, const struct TALER_ReservePublicKeyP *reserve_pub, const char *receiver_account, - const struct TALER_WireTransferIdentifierRawP *transfer_details) + const struct + TALER_WireTransferIdentifierRawP *transfer_details) { struct ReserveContext *rc = cls; struct GNUNET_HashCode key; @@ -1468,7 +1487,8 @@ verify_reserve_balance (void *cls, /* Check that reserve is being closed if it is past its expiration date */ if ( (CLOSING_GRACE_PERIOD.rel_value_us > - GNUNET_TIME_absolute_get_duration (rs->a_expiration_date).rel_value_us) && + GNUNET_TIME_absolute_get_duration ( + rs->a_expiration_date).rel_value_us) && ( (0 != balance.value) || (0 != balance.fraction) ) ) { @@ -1483,7 +1503,8 @@ verify_reserve_balance (void *cls, "balance", TALER_JSON_from_amount (&balance), "expiration_time", - GNUNET_STRINGS_absolute_time_to_string (rs->a_expiration_date))); + GNUNET_STRINGS_absolute_time_to_string ( + rs->a_expiration_date))); } /* Add withdraw fees we encountered to totals */ @@ -1578,7 +1599,7 @@ verify_reserve_balance (void *cls, ret = GNUNET_SYSERR; rc->qs = qs; } - cleanup: + cleanup: GNUNET_assert (GNUNET_YES == GNUNET_CONTAINER_multihashmap_remove (rc->reserves, key, @@ -1616,12 +1637,13 @@ analyze_reserves (void *cls) if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qsp) { GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, - _("First analysis using this auditor, starting audit from scratch\n")); + _ ( + "First analysis using this auditor, starting audit from scratch\n")); } else { GNUNET_log (GNUNET_ERROR_TYPE_INFO, - _("Resuming reserve audit at %llu/%llu/%llu/%llu\n"), + _ ("Resuming reserve audit at %llu/%llu/%llu/%llu\n"), (unsigned long long) ppr.last_reserve_in_serial_id, (unsigned long long) ppr.last_reserve_out_serial_id, (unsigned long long) ppr.last_reserve_payback_serial_id, @@ -1675,7 +1697,8 @@ analyze_reserves (void *cls) } qs = edb->select_reserve_closed_above_serial_id (edb->cls, esession, - ppr.last_reserve_close_serial_id, + ppr. + last_reserve_close_serial_id, &handle_reserve_closed, &rc); if (qs < 0) @@ -1729,12 +1752,12 @@ analyze_reserves (void *cls) if (0 >= qs) { GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "Failed to update auditor DB, not recording progress\n"); + "Failed to update auditor DB, not recording progress\n"); GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); return qs; } GNUNET_log (GNUNET_ERROR_TYPE_INFO, - _("Concluded reserve audit step at %llu/%llu/%llu/%llu\n"), + _ ("Concluded reserve audit step at %llu/%llu/%llu/%llu\n"), (unsigned long long) ppr.last_reserve_in_serial_id, (unsigned long long) ppr.last_reserve_out_serial_id, (unsigned long long) ppr.last_reserve_payback_serial_id, @@ -1939,11 +1962,17 @@ struct WireCheckContext * @return #GNUNET_OK on success, #GNUNET_SYSERR on error */ static int -check_transaction_history_for_deposit (const struct TALER_CoinSpendPublicKeyP *coin_pub, - const struct GNUNET_HashCode *h_contract_terms, - const struct TALER_MerchantPublicKeyP *merchant_pub, - const struct TALER_EXCHANGEDB_DenominationKeyInformationP *dki, - const struct TALER_EXCHANGEDB_TransactionList *tl_head, +check_transaction_history_for_deposit (const struct + TALER_CoinSpendPublicKeyP *coin_pub, + const struct + GNUNET_HashCode *h_contract_terms, + const struct + TALER_MerchantPublicKeyP *merchant_pub, + const struct + TALER_EXCHANGEDB_DenominationKeyInformationP + *dki, + const struct + TALER_EXCHANGEDB_TransactionList *tl_head, struct TALER_Amount *merchant_gain) { struct TALER_Amount expenditures; @@ -1987,7 +2016,8 @@ check_transaction_history_for_deposit (const struct TALER_CoinSpendPublicKeyP *c const struct TALER_AmountNBO *fee_dki; struct TALER_Amount tmp; - switch (tl->type) { + switch (tl->type) + { case TALER_EXCHANGEDB_TT_DEPOSIT: amount_with_fee = &tl->details.deposit->amount_with_fee; fee = &tl->details.deposit->deposit_fee; @@ -2241,12 +2271,14 @@ check_transaction_history_for_deposit (const struct TALER_CoinSpendPublicKeyP *c static void wire_transfer_information_cb (void *cls, uint64_t rowid, - const struct TALER_MerchantPublicKeyP *merchant_pub, + const struct + TALER_MerchantPublicKeyP *merchant_pub, const struct GNUNET_HashCode *h_wire, const json_t *account_details, struct GNUNET_TIME_Absolute exec_time, const struct GNUNET_HashCode *h_contract_terms, - const struct TALER_DenominationPublicKey *denom_pub, + const struct + TALER_DenominationPublicKey *denom_pub, const struct TALER_CoinSpendPublicKeyP *coin_pub, const struct TALER_Amount *coin_value, const struct TALER_Amount *deposit_fee) @@ -2343,7 +2375,8 @@ wire_transfer_information_cb (void *cls, "operation", "wire", "row", (json_int_t) rowid, "loss", TALER_JSON_from_amount (coin_value), - "key_pub", GNUNET_JSON_from_data_auto (&dki->properties.denom_hash))); + "key_pub", GNUNET_JSON_from_data_auto ( + &dki->properties.denom_hash))); GNUNET_break (GNUNET_OK == TALER_amount_add (&total_bad_sig_loss, &total_bad_sig_loss, @@ -2434,8 +2467,8 @@ wire_transfer_information_cb (void *cls, /* Add coin's contribution to total aggregate value */ if (GNUNET_OK != TALER_amount_add (&wcc->total_deposits, - &wcc->total_deposits, - &coin_value_without_fee)) + &wcc->total_deposits, + &coin_value_without_fee)) { GNUNET_break (0); wcc->qs = GNUNET_DB_STATUS_HARD_ERROR; @@ -2542,7 +2575,8 @@ get_wire_fee (struct AggregationContext *ac, json_pack ("{s:s, s:s, s:s}", "type", type, "diagnostic", "start date before previous end date", - "time", GNUNET_STRINGS_absolute_time_to_string (wfi->start_date))); + "time", GNUNET_STRINGS_absolute_time_to_string ( + wfi->start_date))); } if ( (NULL != wfi->next) && (wfi->next->start_date.abs_value_us >= wfi->end_date.abs_value_us) ) @@ -2551,7 +2585,8 @@ get_wire_fee (struct AggregationContext *ac, json_pack ("{s:s, s:s, s:s}", "type", type, "diagnostic", "end date date after next start date", - "time", GNUNET_STRINGS_absolute_time_to_string (wfi->end_date))); + "time", GNUNET_STRINGS_absolute_time_to_string ( + wfi->end_date))); } return &wfi->wire_fee; } @@ -2572,11 +2607,11 @@ get_wire_fee (struct AggregationContext *ac, static int check_wire_out_cb (void *cls, - uint64_t rowid, - struct GNUNET_TIME_Absolute date, - const struct TALER_WireTransferIdentifierRawP *wtid, - const json_t *wire, - const struct TALER_Amount *amount) + uint64_t rowid, + struct GNUNET_TIME_Absolute date, + const struct TALER_WireTransferIdentifierRawP *wtid, + const json_t *wire, + const struct TALER_Amount *amount) { struct AggregationContext *ac = cls; struct WireCheckContext wcc; @@ -2659,10 +2694,10 @@ check_wire_out_cb report_amount_arithmetic_inconsistency ("wire out (fee structure)", - rowid, - &wcc.total_deposits, - wire_fee, - -1); + rowid, + &wcc.total_deposits, + wire_fee, + -1); GNUNET_free (method); return GNUNET_OK; @@ -2670,8 +2705,8 @@ check_wire_out_cb /* Round down to amount supported by wire method */ plugin = get_wire_plugin - (ac, - TALER_WIRE_get_plugin_from_method (method)); + (ac, + TALER_WIRE_get_plugin_from_method (method)); if (NULL == plugin) { GNUNET_break (0); @@ -2786,12 +2821,13 @@ analyze_aggregations (void *cls) if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qsp) { GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, - _("First analysis using this auditor, starting audit from scratch\n")); + _ ( + "First analysis using this auditor, starting audit from scratch\n")); } else { GNUNET_log (GNUNET_ERROR_TYPE_INFO, - _("Resuming aggregation audit at %llu\n"), + _ ("Resuming aggregation audit at %llu\n"), (unsigned long long) ppa.last_wire_out_serial_id); } @@ -2799,9 +2835,9 @@ analyze_aggregations (void *cls) 0, sizeof (ac)); qsx = adb->get_wire_fee_summary (adb->cls, - asession, - &master_pub, - &total_aggregation_fee_income); + asession, + &master_pub, + &total_aggregation_fee_income); if (0 > qsx) { GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qsx); @@ -2809,10 +2845,10 @@ analyze_aggregations (void *cls) } ac.qs = GNUNET_DB_STATUS_SUCCESS_ONE_RESULT; qs = edb->select_wire_out_above_serial_id (edb->cls, - esession, - ppa.last_wire_out_serial_id, - &check_wire_out_cb, - &ac); + esession, + ppa.last_wire_out_serial_id, + &check_wire_out_cb, + &ac); if (0 > qs) { GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); @@ -2867,12 +2903,12 @@ analyze_aggregations (void *cls) if (0 >= qs) { GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "Failed to update auditor DB, not recording progress\n"); + "Failed to update auditor DB, not recording progress\n"); GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); return qs; } GNUNET_log (GNUNET_ERROR_TYPE_INFO, - _("Concluded aggregation audit step at %llu\n"), + _ ("Concluded aggregation audit step at %llu\n"), (unsigned long long) ppa.last_wire_out_serial_id); return GNUNET_DB_STATUS_SUCCESS_ONE_RESULT; @@ -3006,14 +3042,16 @@ init_denomination (const struct GNUNET_HashCode *denom_hash, /* check revocation signature */ struct TALER_MasterDenominationKeyRevocationPS rm; - rm.purpose.purpose = htonl (TALER_SIGNATURE_MASTER_DENOMINATION_KEY_REVOKED); + rm.purpose.purpose = htonl ( + TALER_SIGNATURE_MASTER_DENOMINATION_KEY_REVOKED); rm.purpose.size = htonl (sizeof (rm)); rm.h_denom_pub = *denom_hash; if (GNUNET_OK != - GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_MASTER_DENOMINATION_KEY_REVOKED, - &rm.purpose, - &msig.eddsa_signature, - &master_pub.eddsa_pub)) + GNUNET_CRYPTO_eddsa_verify ( + TALER_SIGNATURE_MASTER_DENOMINATION_KEY_REVOKED, + &rm.purpose, + &msig.eddsa_signature, + &master_pub.eddsa_pub)) { report_row_inconsistency ("denomination revocation table", rowid, @@ -3051,7 +3089,8 @@ init_denomination (const struct GNUNET_HashCode *denom_hash, */ static struct DenominationSummary * get_denomination_summary (struct CoinContext *cc, - const struct TALER_EXCHANGEDB_DenominationKeyInformationP *dki, + const struct + TALER_EXCHANGEDB_DenominationKeyInformationP *dki, const struct GNUNET_HashCode *dh) { struct DenominationSummary *ds; @@ -3112,8 +3151,8 @@ sync_denomination (void *cls, outstanding coins as revenue; and reduce cc->risk exposure. */ if (ds->in_db) qs = adb->del_denomination_balance (adb->cls, - asession, - denom_hash); + asession, + denom_hash); else qs = GNUNET_DB_STATUS_SUCCESS_ONE_RESULT; if ( (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qs) && @@ -3372,7 +3411,7 @@ reveal_data_cb (void *cls, rctx->num_newcoins = num_newcoins; rctx->new_dps = GNUNET_new_array (num_newcoins, struct TALER_DenominationPublicKey); - for (unsigned int i=0;inew_dps[i].rsa_public_key = GNUNET_CRYPTO_rsa_public_key_dup (rrcs[i].denom_pub.rsa_public_key); } @@ -3502,12 +3541,14 @@ refresh_session_cb (void *cls, } { - const struct TALER_EXCHANGEDB_DenominationKeyInformationP *new_dkis[reveal_ctx.num_newcoins]; + const struct + TALER_EXCHANGEDB_DenominationKeyInformationP *new_dkis[reveal_ctx. + num_newcoins]; /* Update outstanding amounts for all new coin's denominations, and check that the resulting amounts are consistent with the value being refreshed. */ err = GNUNET_NO; - for (unsigned int i=0;iqs = qs; err = GNUNET_YES; } - GNUNET_CRYPTO_rsa_public_key_free (reveal_ctx.new_dps[i].rsa_public_key); + GNUNET_CRYPTO_rsa_public_key_free ( + reveal_ctx.new_dps[i].rsa_public_key); reveal_ctx.new_dps[i].rsa_public_key = NULL; } GNUNET_free (reveal_ctx.new_dps); @@ -3529,7 +3571,7 @@ refresh_session_cb (void *cls, return GNUNET_SYSERR; /* calculate total refresh cost */ - for (unsigned int i=0;icoin_pub))); + "coin_pub", GNUNET_JSON_from_data_auto ( + &coin->coin_pub))); GNUNET_break (GNUNET_OK == TALER_amount_add (&total_bad_sig_loss, &total_bad_sig_loss, @@ -4116,7 +4160,8 @@ check_payback (struct CoinContext *cc, "operation", "payback (denomination not revoked)", "row", (json_int_t) rowid, "loss", TALER_JSON_from_amount (amount), - "coin_pub", GNUNET_JSON_from_data_auto (&coin->coin_pub))); + "coin_pub", GNUNET_JSON_from_data_auto ( + &coin->coin_pub))); } GNUNET_break (GNUNET_OK == TALER_amount_add (&ds->denom_payback, @@ -4231,12 +4276,13 @@ analyze_coins (void *cls) if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qsp) { GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, - _("First analysis using this auditor, starting audit from scratch\n")); + _ ( + "First analysis using this auditor, starting audit from scratch\n")); } else { GNUNET_log (GNUNET_ERROR_TYPE_INFO, - _("Resuming coin audit at %llu/%llu/%llu/%llu/%llu\n"), + _ ("Resuming coin audit at %llu/%llu/%llu/%llu/%llu\n"), (unsigned long long) ppc.last_deposit_serial_id, (unsigned long long) ppc.last_melt_serial_id, (unsigned long long) ppc.last_refund_serial_id, @@ -4267,7 +4313,8 @@ analyze_coins (void *cls) if (0 > (qs = edb->select_reserves_out_above_serial_id (edb->cls, esession, - ppc.last_withdraw_serial_id, + ppc. + last_withdraw_serial_id, &withdraw_cb, &cc)) ) { @@ -4325,7 +4372,8 @@ analyze_coins (void *cls) if (0 > (qs = edb->select_payback_refresh_above_serial_id (edb->cls, esession, - ppc.last_payback_refresh_serial_id, + ppc. + last_payback_refresh_serial_id, &payback_refresh_cb, &cc))) { @@ -4383,12 +4431,12 @@ analyze_coins (void *cls) if (0 >= qs) { GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "Failed to update auditor DB, not recording progress\n"); + "Failed to update auditor DB, not recording progress\n"); GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); return qs; } GNUNET_log (GNUNET_ERROR_TYPE_INFO, - _("Concluded coin audit step at %llu/%llu/%llu/%llu/%llu\n"), + _ ("Concluded coin audit step at %llu/%llu/%llu/%llu/%llu\n"), (unsigned long long) ppc.last_deposit_serial_id, (unsigned long long) ppc.last_melt_serial_id, (unsigned long long) ppc.last_refund_serial_id, @@ -4528,12 +4576,13 @@ analyze_deposit_confirmations (void *cls) if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qsp) { GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, - _("First analysis using this auditor, starting audit from scratch\n")); + _ ( + "First analysis using this auditor, starting audit from scratch\n")); } else { GNUNET_log (GNUNET_ERROR_TYPE_INFO, - _("Resuming deposit confirmation audit at %llu\n"), + _ ("Resuming deposit confirmation audit at %llu\n"), (unsigned long long) ppdc.last_deposit_confirmation_serial_id); } @@ -4579,7 +4628,7 @@ analyze_deposit_confirmations (void *cls) if (0 >= qs) { GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "Failed to update auditor DB, not recording progress\n"); + "Failed to update auditor DB, not recording progress\n"); GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); return qs; } @@ -4587,7 +4636,7 @@ analyze_deposit_confirmations (void *cls) total_missed_deposit_confirmations = dcc.missed_amount; GNUNET_log (GNUNET_ERROR_TYPE_INFO, - _("Concluded deposit confirmation audit step at %llu\n"), + _ ("Concluded deposit confirmation audit step at %llu\n"), (unsigned long long) ppdc.last_deposit_confirmation_serial_id); return qs; } @@ -4657,10 +4706,10 @@ transact (Analysis analysis, else { qs = adb->commit (adb->cls, - asession); + asession); if (0 > qs) { - GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); + GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Auditor DB commit failed!\n"); } @@ -4781,7 +4830,8 @@ run (void *cls, } if (GNUNET_OK != GNUNET_CRYPTO_eddsa_public_key_from_string (master_public_key_str, - strlen (master_public_key_str), + strlen ( + master_public_key_str), &master_pub.eddsa_pub)) { fprintf (stderr, @@ -4807,9 +4857,9 @@ run (void *cls, } if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_time (cfg, - "exchangedb", - "IDLE_RESERVE_EXPIRATION_TIME", - &idle_reserve_expiration_time)) + "exchangedb", + "IDLE_RESERVE_EXPIRATION_TIME", + &idle_reserve_expiration_time)) { GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, "exchangedb", @@ -4946,33 +4996,36 @@ run (void *cls, TALER_amount_get_zero (currency, &total_refresh_hanging)); GNUNET_assert (NULL != - (report_emergencies = json_array ())); + (report_emergencies = json_array ())); GNUNET_assert (NULL != - (report_row_inconsistencies = json_array ())); + (report_row_inconsistencies = json_array ())); GNUNET_assert (NULL != - (denomination_key_validity_withdraw_inconsistencies = json_array ())); + (denomination_key_validity_withdraw_inconsistencies = + json_array ())); GNUNET_assert (NULL != - (report_reserve_balance_summary_wrong_inconsistencies = json_array ())); + (report_reserve_balance_summary_wrong_inconsistencies = + json_array ())); GNUNET_assert (NULL != - (report_reserve_balance_insufficient_inconsistencies = json_array ())); + (report_reserve_balance_insufficient_inconsistencies = + json_array ())); GNUNET_assert (NULL != - (report_reserve_not_closed_inconsistencies = json_array ())); + (report_reserve_not_closed_inconsistencies = json_array ())); GNUNET_assert (NULL != - (report_wire_out_inconsistencies = json_array ())); + (report_wire_out_inconsistencies = json_array ())); GNUNET_assert (NULL != - (report_deposit_confirmation_inconsistencies = json_array ())); + (report_deposit_confirmation_inconsistencies = json_array ())); GNUNET_assert (NULL != - (report_coin_inconsistencies = json_array ())); + (report_coin_inconsistencies = json_array ())); GNUNET_assert (NULL != - (report_aggregation_fee_balances = json_array ())); + (report_aggregation_fee_balances = json_array ())); GNUNET_assert (NULL != - (report_amount_arithmetic_inconsistencies = json_array ())); + (report_amount_arithmetic_inconsistencies = json_array ())); GNUNET_assert (NULL != - (report_bad_sig_losses = json_array ())); + (report_bad_sig_losses = json_array ())); GNUNET_assert (NULL != - (report_refreshs_hanging = json_array ())); + (report_refreshs_hanging = json_array ())); GNUNET_assert (NULL != - (report_fee_time_inconsistencies = json_array ())); + (report_fee_time_inconsistencies = json_array ())); setup_sessions_and_run (); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Audit complete\n"); @@ -5008,9 +5061,11 @@ run (void *cls, "reserve_balance_summary_wrong_inconsistencies", report_reserve_balance_summary_wrong_inconsistencies, "total_balance_summary_delta_plus", - TALER_JSON_from_amount (&total_balance_summary_delta_plus), + TALER_JSON_from_amount ( + &total_balance_summary_delta_plus), "total_balance_summary_delta_minus", - TALER_JSON_from_amount (&total_balance_summary_delta_minus), + TALER_JSON_from_amount ( + &total_balance_summary_delta_minus), /* block */ "total_escrow_balance", TALER_JSON_from_amount (&total_escrow_balance), @@ -5035,7 +5090,8 @@ run (void *cls, report_reserve_not_closed_inconsistencies, /* block */ "total_balance_reserve_not_closed", - TALER_JSON_from_amount (&total_balance_reserve_not_closed), + TALER_JSON_from_amount ( + &total_balance_reserve_not_closed), "wire_out_inconsistencies", report_wire_out_inconsistencies, "total_wire_out_delta_plus", @@ -5079,14 +5135,15 @@ run (void *cls, (json_int_t) number_missed_deposit_confirmations, /* block */ "missing_deposit_confirmation_total", - TALER_JSON_from_amount (&total_missed_deposit_confirmations), + TALER_JSON_from_amount ( + &total_missed_deposit_confirmations), "total_payback_loss", TALER_JSON_from_amount (&total_payback_loss) ); GNUNET_break (NULL != report); json_dumpf (report, - stdout, - JSON_INDENT (2)); + stdout, + JSON_INDENT (2)); json_decref (report); } diff --git a/src/auditor/taler-wire-auditor.c b/src/auditor/taler-wire-auditor.c index f0b118539..a94cd5f68 100644 --- a/src/auditor/taler-wire-auditor.c +++ b/src/auditor/taler-wire-auditor.c @@ -90,7 +90,7 @@ struct WireAccount * Number of bytes in #in_wire_off and #out_wire_off. */ size_t wire_off_size; - + /** * We should check for inbound transactions to this account. */ @@ -556,7 +556,7 @@ commit (enum GNUNET_DB_QueryStatus qs) GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); return qs; } - } + } if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qsx) qs = adb->update_wire_auditor_progress (adb->cls, asession, @@ -652,7 +652,8 @@ wire_missing_cb (void *cls, json_pack ("{s:I, s:o, s:s, s:s, s:o, s:O}", "row", (json_int_t) rowid, "amount", TALER_JSON_from_amount (amount), - "deadline", GNUNET_STRINGS_absolute_time_to_string (deadline), + "deadline", GNUNET_STRINGS_absolute_time_to_string ( + deadline), "claimed_done", (done) ? "yes" : "no", "coin_pub", GNUNET_JSON_from_data_auto (coin_pub), "account", wire)); @@ -663,7 +664,7 @@ wire_missing_cb (void *cls, /** * Checks that all wire transfers that should have happened * (based on deposits) have indeed happened. - * + * * FIXME: this check _might_ rather belong with the * taler-auditor logic. */ @@ -672,7 +673,7 @@ check_for_required_transfers () { struct GNUNET_TIME_Absolute next_timestamp; enum GNUNET_DB_QueryStatus qs; - + next_timestamp = GNUNET_TIME_absolute_get (); (void) GNUNET_TIME_round_abs (&next_timestamp); /* Subtract #GRACE_PERIOD, so we can be a bit behind in processing @@ -761,7 +762,8 @@ wire_out_cb (void *cls, "amount_wired", TALER_JSON_from_amount (&zero), "amount_justified", TALER_JSON_from_amount (amount), "wtid", GNUNET_JSON_from_data_auto (wtid), - "timestamp", GNUNET_STRINGS_absolute_time_to_string (date), + "timestamp", GNUNET_STRINGS_absolute_time_to_string ( + date), "diagnostic", "wire transfer not made (yet?)")); GNUNET_break (GNUNET_OK == TALER_amount_add (&total_bad_amount_out_minus, @@ -782,10 +784,12 @@ wire_out_cb (void *cls, report (report_wire_out_inconsistencies, json_pack ("{s:I, s:o, s:o, s:o, s:s, s:s}", "row", (json_int_t) rowid, - "amount_wired", TALER_JSON_from_amount (&roi->details.amount), + "amount_wired", TALER_JSON_from_amount ( + &roi->details.amount), "amount_justified", TALER_JSON_from_amount (&zero), "wtid", GNUNET_JSON_from_data_auto (wtid), - "timestamp", GNUNET_STRINGS_absolute_time_to_string (date), + "timestamp", GNUNET_STRINGS_absolute_time_to_string ( + date), "diagnostic", "recevier account missmatch")); GNUNET_break (GNUNET_OK == TALER_amount_add (&total_bad_amount_out_plus, @@ -797,7 +801,8 @@ wire_out_cb (void *cls, "amount_wired", TALER_JSON_from_amount (&zero), "amount_justified", TALER_JSON_from_amount (amount), "wtid", GNUNET_JSON_from_data_auto (wtid), - "timestamp", GNUNET_STRINGS_absolute_time_to_string (date), + "timestamp", GNUNET_STRINGS_absolute_time_to_string ( + date), "diagnostic", "receiver account missmatch")); GNUNET_break (GNUNET_OK == TALER_amount_add (&total_bad_amount_out_minus, @@ -815,9 +820,11 @@ wire_out_cb (void *cls, json_pack ("{s:I, s:o, s:o, s:o, s:s, s:s}", "row", (json_int_t) rowid, "amount_justified", TALER_JSON_from_amount (amount), - "amount_wired", TALER_JSON_from_amount (&roi->details.amount), + "amount_wired", TALER_JSON_from_amount ( + &roi->details.amount), "wtid", GNUNET_JSON_from_data_auto (wtid), - "timestamp", GNUNET_STRINGS_absolute_time_to_string (date), + "timestamp", GNUNET_STRINGS_absolute_time_to_string ( + date), "diagnostic", "wire amount does not match")); if (0 < TALER_amount_cmp (amount, &roi->details.amount)) @@ -859,7 +866,7 @@ wire_out_cb (void *cls, "row", (json_int_t) rowid, "diagnostic", "execution date missmatch")); } -cleanup: + cleanup: GNUNET_assert (GNUNET_OK == GNUNET_CONTAINER_multihashmap_remove (out_map, &key, @@ -894,13 +901,16 @@ complain_out_not_found (void *cls, report (report_wire_out_inconsistencies, json_pack ("{s:I, s:o, s:o, s:o, s:s, s:s}", "row", (json_int_t) 0, - "amount_wired", TALER_JSON_from_amount (&roi->details.amount), + "amount_wired", TALER_JSON_from_amount ( + &roi->details.amount), "amount_justified", TALER_JSON_from_amount (&zero), "wtid", (NULL == roi->details.wtid_s) ? GNUNET_JSON_from_data_auto (&roi->details.wtid) : json_string (roi->details.wtid_s), - "timestamp", GNUNET_STRINGS_absolute_time_to_string (roi->details.execution_date), - "diagnostic", "justification for wire transfer not found")); + "timestamp", GNUNET_STRINGS_absolute_time_to_string ( + roi->details.execution_date), + "diagnostic", + "justification for wire transfer not found")); GNUNET_break (GNUNET_OK == TALER_amount_add (&total_bad_amount_out_plus, &total_bad_amount_out_plus, @@ -937,7 +947,8 @@ check_exchange_wire_out (struct WireAccount *wa) qs = edb->select_wire_out_above_serial_id_by_account (edb->cls, esession, wa->section_name, - wa->pp.last_wire_out_serial_id, + wa->pp. + last_wire_out_serial_id, &wire_out_cb, wa); if (0 > qs) @@ -1093,7 +1104,7 @@ process_debits (void *cls) struct WireAccount *wa = cls; struct TALER_WIRE_Plugin *wp; - /* skip accounts where DEBIT is not enabled */ + /* skip accounts where DEBIT is not enabled */ while ( (NULL != wa) && (GNUNET_NO == wa->watch_debit) ) wa = wa->next; @@ -1193,8 +1204,8 @@ reserve_in_cb (void *cls, TALER_B2S (reserve_pub)); rii = GNUNET_new (struct ReserveInInfo); GNUNET_CRYPTO_hash (wire_reference, - wire_reference_size, - &rii->row_off_hash); + wire_reference_size, + &rii->row_off_hash); rii->row_off_size = wire_reference_size; rii->details.amount = *credit; rii->details.execution_date = execution_date; @@ -1216,7 +1227,8 @@ reserve_in_cb (void *cls, json_pack ("{s:s, s:I, s:o, s:s}", "table", "reserves_in", "row", (json_int_t) rowid, - "wire_offset_hash", GNUNET_JSON_from_data_auto (&rii->row_off_hash), + "wire_offset_hash", GNUNET_JSON_from_data_auto ( + &rii->row_off_hash), "diagnostic", "duplicate wire offset")); GNUNET_free (rii->details.account_url); GNUNET_free_non_null (rii->details.wtid_s); /* field not used (yet) */ @@ -1248,11 +1260,14 @@ complain_in_not_found (void *cls, report (report_reserve_in_inconsistencies, json_pack ("{s:I, s:o, s:o, s:o, s:s, s:s}", "row", (json_int_t) rii->rowid, - "amount_expected", TALER_JSON_from_amount (&rii->details.amount), + "amount_expected", TALER_JSON_from_amount ( + &rii->details.amount), "amount_wired", TALER_JSON_from_amount (&zero), "wtid", GNUNET_JSON_from_data_auto (&rii->details.wtid), - "timestamp", GNUNET_STRINGS_absolute_time_to_string (rii->details.execution_date), - "diagnostic", "incoming wire transfer claimed by exchange not found")); + "timestamp", GNUNET_STRINGS_absolute_time_to_string ( + rii->details.execution_date), + "diagnostic", + "incoming wire transfer claimed by exchange not found")); GNUNET_break (GNUNET_OK == TALER_amount_add (&total_bad_amount_in_minus, &total_bad_amount_in_minus, @@ -1334,7 +1349,8 @@ history_credit_cb (void *cls, { GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Failed to find wire transfer at `%s' in exchange database. Audit ends at this point in time.\n", - GNUNET_STRINGS_absolute_time_to_string (details->execution_date)); + GNUNET_STRINGS_absolute_time_to_string ( + details->execution_date)); wa->hh = NULL; process_credits (wa->next); return GNUNET_SYSERR; /* not an error, just end of processing */ @@ -1376,10 +1392,12 @@ history_credit_cb (void *cls, report (report_reserve_in_inconsistencies, json_pack ("{s:I, s:o, s:o, s:o, s:s, s:s}", "row", GNUNET_JSON_from_data (row_off, row_off_size), - "amount_exchange_expected", TALER_JSON_from_amount (&rii->details.amount), + "amount_exchange_expected", TALER_JSON_from_amount ( + &rii->details.amount), "amount_wired", TALER_JSON_from_amount (&zero), "wtid", GNUNET_JSON_from_data_auto (&rii->details.wtid), - "timestamp", GNUNET_STRINGS_absolute_time_to_string (rii->details.execution_date), + "timestamp", GNUNET_STRINGS_absolute_time_to_string ( + rii->details.execution_date), "diagnostic", "wire subject does not match")); GNUNET_break (GNUNET_OK == TALER_amount_add (&total_bad_amount_in_minus, @@ -1388,10 +1406,13 @@ history_credit_cb (void *cls, report (report_reserve_in_inconsistencies, json_pack ("{s:I, s:o, s:o, s:o, s:s, s:s}", "row", GNUNET_JSON_from_data (row_off, row_off_size), - "amount_exchange_expected", TALER_JSON_from_amount (&zero), - "amount_wired", TALER_JSON_from_amount (&details->amount), + "amount_exchange_expected", TALER_JSON_from_amount ( + &zero), + "amount_wired", TALER_JSON_from_amount ( + &details->amount), "wtid", GNUNET_JSON_from_data_auto (&details->wtid), - "timestamp", GNUNET_STRINGS_absolute_time_to_string (details->execution_date), + "timestamp", GNUNET_STRINGS_absolute_time_to_string ( + details->execution_date), "diagnostic", "wire subject does not match")); GNUNET_break (GNUNET_OK == @@ -1406,10 +1427,13 @@ history_credit_cb (void *cls, report (report_reserve_in_inconsistencies, json_pack ("{s:I, s:o, s:o, s:o, s:s, s:s}", "row", GNUNET_JSON_from_data (row_off, row_off_size), - "amount_exchange_expected", TALER_JSON_from_amount (&rii->details.amount), - "amount_wired", TALER_JSON_from_amount (&details->amount), + "amount_exchange_expected", TALER_JSON_from_amount ( + &rii->details.amount), + "amount_wired", TALER_JSON_from_amount ( + &details->amount), "wtid", GNUNET_JSON_from_data_auto (&details->wtid), - "timestamp", GNUNET_STRINGS_absolute_time_to_string (details->execution_date), + "timestamp", GNUNET_STRINGS_absolute_time_to_string ( + details->execution_date), "diagnostic", "wire amount does not match")); if (0 < TALER_amount_cmp (&details->amount, &rii->details.amount)) @@ -1449,7 +1473,8 @@ history_credit_cb (void *cls, json_pack ("{s:s, s:o, s:o}", "amount", TALER_JSON_from_amount (&rii->details.amount), "row", GNUNET_JSON_from_data (row_off, row_off_size), - "wtid", GNUNET_JSON_from_data_auto (&rii->details.wtid))); + "wtid", GNUNET_JSON_from_data_auto ( + &rii->details.wtid))); GNUNET_break (GNUNET_OK == TALER_amount_add (&total_missattribution_in, &total_missattribution_in, @@ -1464,7 +1489,7 @@ history_credit_cb (void *cls, "row", GNUNET_JSON_from_data (row_off, row_off_size), "diagnostic", "execution date missmatch")); } - cleanup: + cleanup: GNUNET_assert (GNUNET_OK == free_rii (NULL, &key, @@ -1505,7 +1530,8 @@ process_credits (void *cls) qs = edb->select_reserves_in_above_serial_id_by_account (edb->cls, esession, wa->section_name, - wa->pp.last_reserve_in_serial_id, + wa->pp. + last_reserve_in_serial_id, &reserve_in_cb, wa); if (0 > qs) @@ -1542,7 +1568,7 @@ process_credits (void *cls) /** * Begin audit of CREDITs to the exchange. - */ + */ static void begin_credit_audit () { @@ -1555,7 +1581,7 @@ begin_credit_audit () /** * Start the database transactions and begin the audit. - */ + */ static void begin_transaction () { @@ -1617,7 +1643,8 @@ begin_transaction () if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qsx) { GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, - _("First analysis using this auditor, starting audit from scratch\n")); + _ ( + "First analysis using this auditor, starting audit from scratch\n")); } else { @@ -1739,7 +1766,8 @@ run (void *cls, } if (GNUNET_OK != GNUNET_CRYPTO_eddsa_public_key_from_string (master_public_key_str, - strlen (master_public_key_str), + strlen ( + master_public_key_str), &master_pub.eddsa_pub)) { fprintf (stderr, @@ -1821,19 +1849,19 @@ run (void *cls, return; } GNUNET_assert (NULL != - (report_wire_out_inconsistencies = json_array ())); + (report_wire_out_inconsistencies = json_array ())); GNUNET_assert (NULL != - (report_reserve_in_inconsistencies = json_array ())); + (report_reserve_in_inconsistencies = json_array ())); GNUNET_assert (NULL != - (report_row_minor_inconsistencies = json_array ())); + (report_row_minor_inconsistencies = json_array ())); GNUNET_assert (NULL != - (report_wire_format_inconsistencies = json_array ())); + (report_wire_format_inconsistencies = json_array ())); GNUNET_assert (NULL != - (report_row_inconsistencies = json_array ())); + (report_row_inconsistencies = json_array ())); GNUNET_assert (NULL != - (report_missattribution_in_inconsistencies = json_array ())); + (report_missattribution_in_inconsistencies = json_array ())); GNUNET_assert (NULL != - (report_lags = json_array ())); + (report_lags = json_array ())); GNUNET_assert (GNUNET_OK == TALER_amount_get_zero (currency, &total_bad_amount_out_plus)); diff --git a/src/auditordb/auditordb_plugin.c b/src/auditordb/auditordb_plugin.c index 6aa0274f8..51ae77c16 100644 --- a/src/auditordb/auditordb_plugin.c +++ b/src/auditordb/auditordb_plugin.c @@ -55,7 +55,7 @@ TALER_AUDITORDB_plugin_load (const struct GNUNET_CONFIGURATION_Handle *cfg) GNUNET_free (plugin_name); cfg_dup = GNUNET_CONFIGURATION_dup (cfg); plugin = GNUNET_PLUGIN_load (lib_name, - cfg_dup); + cfg_dup); if (NULL != plugin) plugin->library_name = lib_name; else diff --git a/src/auditordb/plugin_auditordb_postgres.c b/src/auditordb/plugin_auditordb_postgres.c index f1eaa6f2c..555c3058b 100644 --- a/src/auditordb/plugin_auditordb_postgres.c +++ b/src/auditordb/plugin_auditordb_postgres.c @@ -27,7 +27,8 @@ #include -#define LOG(kind,...) GNUNET_log_from (kind, "taler-auditordb-postgres", __VA_ARGS__) +#define LOG(kind,...) GNUNET_log_from (kind, "taler-auditordb-postgres", \ + __VA_ARGS__) /** @@ -37,7 +38,8 @@ * @param field name of the database field to fetch amount from * @param amountp[out] pointer to amount to set */ -#define TALER_PQ_RESULT_SPEC_AMOUNT(field,amountp) TALER_PQ_result_spec_amount(field,pg->currency,amountp) +#define TALER_PQ_RESULT_SPEC_AMOUNT(field,amountp) TALER_PQ_result_spec_amount ( \ + field,pg->currency,amountp) /** * Wrapper macro to add the currency from the plugin's state @@ -46,7 +48,9 @@ * @param field name of the database field to fetch amount from * @param amountp[out] pointer to amount to set */ -#define TALER_PQ_RESULT_SPEC_AMOUNT_NBO(field,amountp) TALER_PQ_result_spec_amount_nbo(field,pg->currency,amountp) +#define TALER_PQ_RESULT_SPEC_AMOUNT_NBO(field, \ + amountp) TALER_PQ_result_spec_amount_nbo ( \ + field,pg->currency,amountp) /** @@ -166,19 +170,25 @@ postgres_drop_tables (void *cls, struct GNUNET_PQ_ExecuteStatement es[] = { GNUNET_PQ_make_execute ("DROP TABLE IF EXISTS auditor_predicted_result;"), GNUNET_PQ_make_execute ("DROP TABLE IF EXISTS auditor_historic_ledger;"), - GNUNET_PQ_make_execute ("DROP TABLE IF EXISTS auditor_historic_denomination_revenue;"), + GNUNET_PQ_make_execute ( + "DROP TABLE IF EXISTS auditor_historic_denomination_revenue;"), GNUNET_PQ_make_execute ("DROP TABLE IF EXISTS auditor_balance_summary;"), - GNUNET_PQ_make_execute ("DROP TABLE IF EXISTS auditor_denomination_pending;"), + GNUNET_PQ_make_execute ( + "DROP TABLE IF EXISTS auditor_denomination_pending;"), GNUNET_PQ_make_execute ("DROP TABLE IF EXISTS auditor_reserve_balance;"), GNUNET_PQ_make_execute ("DROP TABLE IF EXISTS auditor_wire_fee_balance;"), GNUNET_PQ_make_execute ("DROP TABLE IF EXISTS auditor_reserves;"), GNUNET_PQ_make_execute ("DROP TABLE IF EXISTS auditor_progress_reserve;"), - GNUNET_PQ_make_execute ("DROP TABLE IF EXISTS auditor_progress_aggregation;"), - GNUNET_PQ_make_execute ("DROP TABLE IF EXISTS auditor_progress_deposit_confirmation;"), + GNUNET_PQ_make_execute ( + "DROP TABLE IF EXISTS auditor_progress_aggregation;"), + GNUNET_PQ_make_execute ( + "DROP TABLE IF EXISTS auditor_progress_deposit_confirmation;"), GNUNET_PQ_make_execute ("DROP TABLE IF EXISTS auditor_progress_coin;"), GNUNET_PQ_make_execute ("DROP TABLE IF EXISTS wire_auditor_progress;"), - GNUNET_PQ_make_execute ("DROP TABLE IF EXISTS wire_auditor_account_progress;"), - GNUNET_PQ_make_execute ("DROP TABLE IF EXISTS deposit_confirmations CASCADE;"), + GNUNET_PQ_make_execute ( + "DROP TABLE IF EXISTS wire_auditor_account_progress;"), + GNUNET_PQ_make_execute ( + "DROP TABLE IF EXISTS deposit_confirmations CASCADE;"), GNUNET_PQ_EXECUTE_STATEMENT_END }; struct GNUNET_PQ_ExecuteStatement esx[] = { @@ -225,14 +235,15 @@ postgres_create_tables (void *cls) ",exchange_url VARCHAR NOT NULL" ")"), /* Table with list of signing keys of exchanges we are auditing */ - GNUNET_PQ_make_execute ("CREATE TABLE IF NOT EXISTS auditor_exchange_signkeys" - "(master_pub BYTEA CONSTRAINT master_pub_ref REFERENCES auditor_exchanges(master_pub) ON DELETE CASCADE" - ",ep_start INT8 NOT NULL" - ",ep_expire INT8 NOT NULL" - ",ep_end INT8 NOT NULL" - ",exchange_pub BYTEA NOT NULL CHECK (LENGTH(exchange_pub)=32)" - ",master_sig BYTEA NOT NULL CHECK (LENGTH(master_sig)=64)" - ")"), + GNUNET_PQ_make_execute ( + "CREATE TABLE IF NOT EXISTS auditor_exchange_signkeys" + "(master_pub BYTEA CONSTRAINT master_pub_ref REFERENCES auditor_exchanges(master_pub) ON DELETE CASCADE" + ",ep_start INT8 NOT NULL" + ",ep_expire INT8 NOT NULL" + ",ep_end INT8 NOT NULL" + ",exchange_pub BYTEA NOT NULL CHECK (LENGTH(exchange_pub)=32)" + ",master_sig BYTEA NOT NULL CHECK (LENGTH(master_sig)=64)" + ")"), /* Table with all of the denomination keys that the auditor is aware of. */ GNUNET_PQ_make_execute ("CREATE TABLE IF NOT EXISTS auditor_denominations" @@ -260,21 +271,24 @@ postgres_create_tables (void *cls) processed. Thus, we need to select those table entries that are strictly larger (and process in monotonically increasing order). */ - GNUNET_PQ_make_execute ("CREATE TABLE IF NOT EXISTS auditor_progress_reserve" - "(master_pub BYTEA CONSTRAINT master_pub_ref REFERENCES auditor_exchanges(master_pub) ON DELETE CASCADE" - ",last_reserve_in_serial_id INT8 NOT NULL DEFAULT 0" - ",last_reserve_out_serial_id INT8 NOT NULL DEFAULT 0" - ",last_reserve_payback_serial_id INT8 NOT NULL DEFAULT 0" - ",last_reserve_close_serial_id INT8 NOT NULL DEFAULT 0" - ")"), - GNUNET_PQ_make_execute ("CREATE TABLE IF NOT EXISTS auditor_progress_aggregation" - "(master_pub BYTEA CONSTRAINT master_pub_ref REFERENCES auditor_exchanges(master_pub) ON DELETE CASCADE" - ",last_wire_out_serial_id INT8 NOT NULL DEFAULT 0" - ")"), - GNUNET_PQ_make_execute ("CREATE TABLE IF NOT EXISTS auditor_progress_deposit_confirmation" - "(master_pub BYTEA CONSTRAINT master_pub_ref REFERENCES auditor_exchanges(master_pub) ON DELETE CASCADE" - ",last_deposit_confirmation_serial_id INT8 NOT NULL DEFAULT 0" - ")"), + GNUNET_PQ_make_execute ( + "CREATE TABLE IF NOT EXISTS auditor_progress_reserve" + "(master_pub BYTEA CONSTRAINT master_pub_ref REFERENCES auditor_exchanges(master_pub) ON DELETE CASCADE" + ",last_reserve_in_serial_id INT8 NOT NULL DEFAULT 0" + ",last_reserve_out_serial_id INT8 NOT NULL DEFAULT 0" + ",last_reserve_payback_serial_id INT8 NOT NULL DEFAULT 0" + ",last_reserve_close_serial_id INT8 NOT NULL DEFAULT 0" + ")"), + GNUNET_PQ_make_execute ( + "CREATE TABLE IF NOT EXISTS auditor_progress_aggregation" + "(master_pub BYTEA CONSTRAINT master_pub_ref REFERENCES auditor_exchanges(master_pub) ON DELETE CASCADE" + ",last_wire_out_serial_id INT8 NOT NULL DEFAULT 0" + ")"), + GNUNET_PQ_make_execute ( + "CREATE TABLE IF NOT EXISTS auditor_progress_deposit_confirmation" + "(master_pub BYTEA CONSTRAINT master_pub_ref REFERENCES auditor_exchanges(master_pub) ON DELETE CASCADE" + ",last_deposit_confirmation_serial_id INT8 NOT NULL DEFAULT 0" + ")"), GNUNET_PQ_make_execute ("CREATE TABLE IF NOT EXISTS auditor_progress_coin" "(master_pub BYTEA CONSTRAINT master_pub_ref REFERENCES auditor_exchanges(master_pub) ON DELETE CASCADE" ",last_withdraw_serial_id INT8 NOT NULL DEFAULT 0" @@ -284,15 +298,16 @@ postgres_create_tables (void *cls) ",last_payback_serial_id INT8 NOT NULL DEFAULT 0" ",last_payback_refresh_serial_id INT8 NOT NULL DEFAULT 0" ")"), - GNUNET_PQ_make_execute ("CREATE TABLE IF NOT EXISTS wire_auditor_account_progress" - "(master_pub BYTEA CONSTRAINT master_pub_ref REFERENCES auditor_exchanges(master_pub) ON DELETE CASCADE" - ",account_name TEXT NOT NULL" - ",last_wire_reserve_in_serial_id INT8 NOT NULL DEFAULT 0" - ",last_wire_wire_out_serial_id INT8 NOT NULL DEFAULT 0" - ",wire_in_off BYTEA" - ",wire_out_off BYTEA" - ")"), - GNUNET_PQ_make_execute ("CREATE TABLE IF NOT EXISTS wire_auditor_progress" + GNUNET_PQ_make_execute ( + "CREATE TABLE IF NOT EXISTS wire_auditor_account_progress" + "(master_pub BYTEA CONSTRAINT master_pub_ref REFERENCES auditor_exchanges(master_pub) ON DELETE CASCADE" + ",account_name TEXT NOT NULL" + ",last_wire_reserve_in_serial_id INT8 NOT NULL DEFAULT 0" + ",last_wire_wire_out_serial_id INT8 NOT NULL DEFAULT 0" + ",wire_in_off BYTEA" + ",wire_out_off BYTEA" + ")"), + GNUNET_PQ_make_execute ("CREATE TABLE IF NOT EXISTS wire_auditor_progress" "(master_pub BYTEA CONSTRAINT master_pub_ref REFERENCES auditor_exchanges(master_pub) ON DELETE CASCADE" ",last_timestamp INT8 NOT NULL" ")"), @@ -325,28 +340,30 @@ postgres_create_tables (void *cls) ")"), /* Table with the sum of the balances of all wire fees (by exchange's master public key) */ - GNUNET_PQ_make_execute ("CREATE TABLE IF NOT EXISTS auditor_wire_fee_balance" - "(master_pub BYTEA CONSTRAINT master_pub_ref REFERENCES auditor_exchanges(master_pub) ON DELETE CASCADE" - ",wire_fee_balance_val INT8 NOT NULL" - ",wire_fee_balance_frac INT4 NOT NULL" - ")"), + GNUNET_PQ_make_execute ( + "CREATE TABLE IF NOT EXISTS auditor_wire_fee_balance" + "(master_pub BYTEA CONSTRAINT master_pub_ref REFERENCES auditor_exchanges(master_pub) ON DELETE CASCADE" + ",wire_fee_balance_val INT8 NOT NULL" + ",wire_fee_balance_frac INT4 NOT NULL" + ")"), /* Table with all of the outstanding denomination coins that the exchange is aware of and what the respective balances are (outstanding as well as issued overall which implies the maximum value at risk). We also count the number of coins issued (withdraw, refresh-reveal) and the number of coins seen at the exchange (refresh-commit, deposit), not just the amounts. */ - GNUNET_PQ_make_execute ("CREATE TABLE IF NOT EXISTS auditor_denomination_pending" - "(denom_pub_hash BYTEA PRIMARY KEY" - " REFERENCES auditor_denominations (denom_pub_hash) ON DELETE CASCADE" - ",denom_balance_val INT8 NOT NULL" - ",denom_balance_frac INT4 NOT NULL" - ",num_issued INT8 NOT NULL" - ",denom_risk_val INT8 NOT NULL" - ",denom_risk_frac INT4 NOT NULL" - ",payback_loss_val INT8 NOT NULL" - ",payback_loss_frac INT4 NOT NULL" - ")"), + GNUNET_PQ_make_execute ( + "CREATE TABLE IF NOT EXISTS auditor_denomination_pending" + "(denom_pub_hash BYTEA PRIMARY KEY" + " REFERENCES auditor_denominations (denom_pub_hash) ON DELETE CASCADE" + ",denom_balance_val INT8 NOT NULL" + ",denom_balance_frac INT4 NOT NULL" + ",num_issued INT8 NOT NULL" + ",denom_risk_val INT8 NOT NULL" + ",denom_risk_frac INT4 NOT NULL" + ",payback_loss_val INT8 NOT NULL" + ",payback_loss_frac INT4 NOT NULL" + ")"), /* Table with the sum of the outstanding coins from "auditor_denomination_pending" (denom_pubs must belong to the respective's exchange's master public key); it represents the @@ -377,27 +394,30 @@ postgres_create_tables (void *cls) historic_reserve_revenue); the deposit, melt and refund fees are given individually; the delta to the revenue_balance is from coins that were withdrawn but never deposited prior to expiration. */ - GNUNET_PQ_make_execute ("CREATE TABLE IF NOT EXISTS auditor_historic_denomination_revenue" - "(master_pub BYTEA CONSTRAINT master_pub_ref REFERENCES auditor_exchanges(master_pub) ON DELETE CASCADE" - ",denom_pub_hash BYTEA PRIMARY KEY CHECK (LENGTH(denom_pub_hash)=64)" - ",revenue_timestamp INT8 NOT NULL" - ",revenue_balance_val INT8 NOT NULL" - ",revenue_balance_frac INT4 NOT NULL" - ",loss_balance_val INT8 NOT NULL" - ",loss_balance_frac INT4 NOT NULL" - ")"), + GNUNET_PQ_make_execute ( + "CREATE TABLE IF NOT EXISTS auditor_historic_denomination_revenue" + "(master_pub BYTEA CONSTRAINT master_pub_ref REFERENCES auditor_exchanges(master_pub) ON DELETE CASCADE" + ",denom_pub_hash BYTEA PRIMARY KEY CHECK (LENGTH(denom_pub_hash)=64)" + ",revenue_timestamp INT8 NOT NULL" + ",revenue_balance_val INT8 NOT NULL" + ",revenue_balance_frac INT4 NOT NULL" + ",loss_balance_val INT8 NOT NULL" + ",loss_balance_frac INT4 NOT NULL" + ")"), /* Table with historic profits from reserves; we eventually GC "auditor_historic_reserve_revenue", and then store the totals in here (by time intervals). */ - GNUNET_PQ_make_execute ("CREATE TABLE IF NOT EXISTS auditor_historic_reserve_summary" - "(master_pub BYTEA CONSTRAINT master_pub_ref REFERENCES auditor_exchanges(master_pub) ON DELETE CASCADE" - ",start_date INT8 NOT NULL" - ",end_date INT8 NOT NULL" - ",reserve_profits_val INT8 NOT NULL" - ",reserve_profits_frac INT4 NOT NULL" - ")"), - GNUNET_PQ_make_try_execute ("CREATE INDEX auditor_historic_reserve_summary_by_master_pub_start_date " - "ON auditor_historic_reserve_summary(master_pub,start_date)"), + GNUNET_PQ_make_execute ( + "CREATE TABLE IF NOT EXISTS auditor_historic_reserve_summary" + "(master_pub BYTEA CONSTRAINT master_pub_ref REFERENCES auditor_exchanges(master_pub) ON DELETE CASCADE" + ",start_date INT8 NOT NULL" + ",end_date INT8 NOT NULL" + ",reserve_profits_val INT8 NOT NULL" + ",reserve_profits_frac INT4 NOT NULL" + ")"), + GNUNET_PQ_make_try_execute ( + "CREATE INDEX auditor_historic_reserve_summary_by_master_pub_start_date " + "ON auditor_historic_reserve_summary(master_pub,start_date)"), /* Table with deposit confirmation sent to us by merchants; we must check that the exchange reported these properly. */ @@ -437,17 +457,19 @@ postgres_create_tables (void *cls) ",balance_val INT8 NOT NULL" ",balance_frac INT4 NOT NULL" ")"), - GNUNET_PQ_make_try_execute ("CREATE INDEX history_ledger_by_master_pub_and_time " - "ON auditor_historic_ledger(master_pub,timestamp)"), + GNUNET_PQ_make_try_execute ( + "CREATE INDEX history_ledger_by_master_pub_and_time " + "ON auditor_historic_ledger(master_pub,timestamp)"), /* Table with the sum of the ledger, auditor_historic_revenue and the auditor_reserve_balance. This is the final amount that the exchange should have in its bank account right now. */ - GNUNET_PQ_make_execute ("CREATE TABLE IF NOT EXISTS auditor_predicted_result" - "(master_pub BYTEA CONSTRAINT master_pub_ref REFERENCES auditor_exchanges(master_pub) ON DELETE CASCADE" - ",balance_val INT8 NOT NULL" - ",balance_frac INT4 NOT NULL" - ")"), + GNUNET_PQ_make_execute ( + "CREATE TABLE IF NOT EXISTS auditor_predicted_result" + "(master_pub BYTEA CONSTRAINT master_pub_ref REFERENCES auditor_exchanges(master_pub) ON DELETE CASCADE" + ",balance_val INT8 NOT NULL" + ",balance_frac INT4 NOT NULL" + ")"), GNUNET_PQ_EXECUTE_STATEMENT_END }; PGconn *conn; @@ -1042,7 +1064,7 @@ postgres_get_session (void *cls) * DB. Needed after the database server restarts as we need to * properly reconnect. */ GNUNET_assert (0 == pthread_setspecific (pc->db_conn_threadlocal, - NULL)); + NULL)); PQfinish (session->conn); GNUNET_free (session); } @@ -1358,7 +1380,8 @@ postgres_list_exchanges (void *cls, static enum GNUNET_DB_QueryStatus postgres_insert_exchange_signkey (void *cls, struct TALER_AUDITORDB_Session *session, - const struct TALER_AUDITORDB_ExchangeSigningKey *sk) + const struct + TALER_AUDITORDB_ExchangeSigningKey *sk) { struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (&sk->master_public_key), @@ -1387,7 +1410,8 @@ postgres_insert_exchange_signkey (void *cls, static enum GNUNET_DB_QueryStatus postgres_insert_deposit_confirmation (void *cls, struct TALER_AUDITORDB_Session *session, - const struct TALER_AUDITORDB_DepositConfirmation *dc) + const struct + TALER_AUDITORDB_DepositConfirmation *dc) { struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (&dc->master_public_key), @@ -1459,7 +1483,7 @@ deposit_confirmation_cb (void *cls, { struct DepositConfirmationContext *dcc = cls; struct PostgresClosure *pg = dcc->pg; - + for (unsigned int i = 0; i < num_results; i++) { uint64_t serial_id; @@ -1494,8 +1518,8 @@ deposit_confirmation_cb (void *cls, if (GNUNET_OK != GNUNET_PQ_extract_result (result, - rs, - i)) + rs, + i)) { GNUNET_break (0); dcc->qs = GNUNET_DB_STATUS_HARD_ERROR; @@ -1524,9 +1548,11 @@ deposit_confirmation_cb (void *cls, static enum GNUNET_DB_QueryStatus postgres_get_deposit_confirmations (void *cls, struct TALER_AUDITORDB_Session *session, - const struct TALER_MasterPublicKeyP *master_public_key, + const struct + TALER_MasterPublicKeyP *master_public_key, uint64_t start_id, - TALER_AUDITORDB_DepositConfirmationCallback cb, + TALER_AUDITORDB_DepositConfirmationCallback + cb, void *cb_cls) { struct PostgresClosure *pg = cls; @@ -1544,10 +1570,10 @@ postgres_get_deposit_confirmations (void *cls, enum GNUNET_DB_QueryStatus qs; qs = GNUNET_PQ_eval_prepared_multi_select (session->conn, - "auditor_deposit_confirmation_select", - params, - &deposit_confirmation_cb, - &dcc); + "auditor_deposit_confirmation_select", + params, + &deposit_confirmation_cb, + &dcc); if (qs > 0) return dcc.qs; GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR != qs); @@ -1569,7 +1595,8 @@ postgres_get_deposit_confirmations (void *cls, static enum GNUNET_DB_QueryStatus postgres_insert_denomination_info (void *cls, struct TALER_AUDITORDB_Session *session, - const struct TALER_DenominationKeyValidityPS *issue) + const struct + TALER_DenominationKeyValidityPS *issue) { struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (&issue->denom_hash), @@ -1598,7 +1625,7 @@ postgres_insert_denomination_info (void *cls, &issue->fee_refresh)); GNUNET_assert (GNUNET_YES == TALER_amount_cmp_currency_nbo (&issue->value, - &issue->fee_refund)); + &issue->fee_refund)); return GNUNET_PQ_eval_prepared_non_select (session->conn, "auditor_denominations_insert", params); @@ -1630,7 +1657,7 @@ struct DenominationInfoContext * Plugin context. */ struct PostgresClosure *pg; - + /** * Query status to return. */ @@ -1661,11 +1688,15 @@ denomination_info_cb (void *cls, .master = *dic->master_pub }; struct GNUNET_PQ_ResultSpec rs[] = { - GNUNET_PQ_result_spec_auto_from_type ("denom_pub_hash", &issue.denom_hash), + GNUNET_PQ_result_spec_auto_from_type ("denom_pub_hash", + &issue.denom_hash), TALER_PQ_result_spec_absolute_time_nbo ("valid_from", &issue.start), - TALER_PQ_result_spec_absolute_time_nbo ("expire_withdraw", &issue.expire_withdraw), - TALER_PQ_result_spec_absolute_time_nbo ("expire_deposit", &issue.expire_deposit), - TALER_PQ_result_spec_absolute_time_nbo ("expire_legal", &issue.expire_legal), + TALER_PQ_result_spec_absolute_time_nbo ("expire_withdraw", + &issue.expire_withdraw), + TALER_PQ_result_spec_absolute_time_nbo ("expire_deposit", + &issue.expire_deposit), + TALER_PQ_result_spec_absolute_time_nbo ("expire_legal", + &issue.expire_legal), TALER_PQ_RESULT_SPEC_AMOUNT_NBO ("coin", &issue.value), TALER_PQ_RESULT_SPEC_AMOUNT_NBO ("fee_withdraw", &issue.fee_withdraw), TALER_PQ_RESULT_SPEC_AMOUNT_NBO ("fee_deposit", &issue.fee_deposit), @@ -1676,8 +1707,8 @@ denomination_info_cb (void *cls, if (GNUNET_OK != GNUNET_PQ_extract_result (result, - rs, - i)) + rs, + i)) { GNUNET_break (0); dic->qs = GNUNET_DB_STATUS_HARD_ERROR; @@ -1685,8 +1716,8 @@ denomination_info_cb (void *cls, } dic->qs = i + 1; if (GNUNET_OK != - dic->cb (dic->cb_cls, - &issue)) + dic->cb (dic->cb_cls, + &issue)) return; } } @@ -1705,8 +1736,10 @@ denomination_info_cb (void *cls, static enum GNUNET_DB_QueryStatus postgres_select_denomination_info (void *cls, struct TALER_AUDITORDB_Session *session, - const struct TALER_MasterPublicKeyP *master_pub, - TALER_AUDITORDB_DenominationInfoDataCallback cb, + const struct + TALER_MasterPublicKeyP *master_pub, + TALER_AUDITORDB_DenominationInfoDataCallback + cb, void *cb_cls) { struct PostgresClosure *pg = cls; @@ -1723,10 +1756,10 @@ postgres_select_denomination_info (void *cls, enum GNUNET_DB_QueryStatus qs; qs = GNUNET_PQ_eval_prepared_multi_select (session->conn, - "auditor_denominations_select", - params, - &denomination_info_cb, - &dic); + "auditor_denominations_select", + params, + &denomination_info_cb, + &dic); if (qs > 0) return dic.qs; GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR != qs); @@ -1746,9 +1779,13 @@ postgres_select_denomination_info (void *cls, */ static enum GNUNET_DB_QueryStatus postgres_insert_auditor_progress_reserve (void *cls, - struct TALER_AUDITORDB_Session *session, - const struct TALER_MasterPublicKeyP *master_pub, - const struct TALER_AUDITORDB_ProgressPointReserve *ppr) + struct TALER_AUDITORDB_Session * + session, + const struct + TALER_MasterPublicKeyP *master_pub, + const struct + TALER_AUDITORDB_ProgressPointReserve * + ppr) { struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (master_pub), @@ -1777,9 +1814,13 @@ postgres_insert_auditor_progress_reserve (void *cls, */ static enum GNUNET_DB_QueryStatus postgres_update_auditor_progress_reserve (void *cls, - struct TALER_AUDITORDB_Session *session, - const struct TALER_MasterPublicKeyP *master_pub, - const struct TALER_AUDITORDB_ProgressPointReserve *ppr) + struct TALER_AUDITORDB_Session * + session, + const struct + TALER_MasterPublicKeyP *master_pub, + const struct + TALER_AUDITORDB_ProgressPointReserve * + ppr) { struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_uint64 (&ppr->last_reserve_in_serial_id), @@ -1808,8 +1849,10 @@ postgres_update_auditor_progress_reserve (void *cls, static enum GNUNET_DB_QueryStatus postgres_get_auditor_progress_reserve (void *cls, struct TALER_AUDITORDB_Session *session, - const struct TALER_MasterPublicKeyP *master_pub, - struct TALER_AUDITORDB_ProgressPointReserve *ppr) + const struct + TALER_MasterPublicKeyP *master_pub, + struct + TALER_AUDITORDB_ProgressPointReserve *ppr) { struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (master_pub), @@ -1846,9 +1889,13 @@ postgres_get_auditor_progress_reserve (void *cls, */ static enum GNUNET_DB_QueryStatus postgres_insert_auditor_progress_aggregation (void *cls, - struct TALER_AUDITORDB_Session *session, - const struct TALER_MasterPublicKeyP *master_pub, - const struct TALER_AUDITORDB_ProgressPointAggregation *ppa) + struct TALER_AUDITORDB_Session * + session, + const struct + TALER_MasterPublicKeyP *master_pub, + const struct + TALER_AUDITORDB_ProgressPointAggregation + *ppa) { struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (master_pub), @@ -1874,9 +1921,13 @@ postgres_insert_auditor_progress_aggregation (void *cls, */ static enum GNUNET_DB_QueryStatus postgres_update_auditor_progress_aggregation (void *cls, - struct TALER_AUDITORDB_Session *session, - const struct TALER_MasterPublicKeyP *master_pub, - const struct TALER_AUDITORDB_ProgressPointAggregation *ppa) + struct TALER_AUDITORDB_Session * + session, + const struct + TALER_MasterPublicKeyP *master_pub, + const struct + TALER_AUDITORDB_ProgressPointAggregation + *ppa) { struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_uint64 (&ppa->last_wire_out_serial_id), @@ -1901,9 +1952,13 @@ postgres_update_auditor_progress_aggregation (void *cls, */ static enum GNUNET_DB_QueryStatus postgres_get_auditor_progress_aggregation (void *cls, - struct TALER_AUDITORDB_Session *session, - const struct TALER_MasterPublicKeyP *master_pub, - struct TALER_AUDITORDB_ProgressPointAggregation *ppa) + struct TALER_AUDITORDB_Session * + session, + const struct + TALER_MasterPublicKeyP *master_pub, + struct + TALER_AUDITORDB_ProgressPointAggregation + *ppa) { struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (master_pub), @@ -1934,9 +1989,15 @@ postgres_get_auditor_progress_aggregation (void *cls, */ static enum GNUNET_DB_QueryStatus postgres_insert_auditor_progress_deposit_confirmation (void *cls, - struct TALER_AUDITORDB_Session *session, - const struct TALER_MasterPublicKeyP *master_pub, - const struct TALER_AUDITORDB_ProgressPointDepositConfirmation *ppdc) + struct + TALER_AUDITORDB_Session * + session, + const struct + TALER_MasterPublicKeyP * + master_pub, + const struct + TALER_AUDITORDB_ProgressPointDepositConfirmation + *ppdc) { struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (master_pub), @@ -1962,9 +2023,15 @@ postgres_insert_auditor_progress_deposit_confirmation (void *cls, */ static enum GNUNET_DB_QueryStatus postgres_update_auditor_progress_deposit_confirmation (void *cls, - struct TALER_AUDITORDB_Session *session, - const struct TALER_MasterPublicKeyP *master_pub, - const struct TALER_AUDITORDB_ProgressPointDepositConfirmation *ppdc) + struct + TALER_AUDITORDB_Session * + session, + const struct + TALER_MasterPublicKeyP * + master_pub, + const struct + TALER_AUDITORDB_ProgressPointDepositConfirmation + *ppdc) { struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_uint64 (&ppdc->last_deposit_confirmation_serial_id), @@ -1989,9 +2056,15 @@ postgres_update_auditor_progress_deposit_confirmation (void *cls, */ static enum GNUNET_DB_QueryStatus postgres_get_auditor_progress_deposit_confirmation (void *cls, - struct TALER_AUDITORDB_Session *session, - const struct TALER_MasterPublicKeyP *master_pub, - struct TALER_AUDITORDB_ProgressPointDepositConfirmation *ppdc) + struct + TALER_AUDITORDB_Session * + session, + const struct + TALER_MasterPublicKeyP * + master_pub, + struct + TALER_AUDITORDB_ProgressPointDepositConfirmation + *ppdc) { struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (master_pub), @@ -2023,8 +2096,10 @@ postgres_get_auditor_progress_deposit_confirmation (void *cls, static enum GNUNET_DB_QueryStatus postgres_insert_auditor_progress_coin (void *cls, struct TALER_AUDITORDB_Session *session, - const struct TALER_MasterPublicKeyP *master_pub, - const struct TALER_AUDITORDB_ProgressPointCoin *ppc) + const struct + TALER_MasterPublicKeyP *master_pub, + const struct + TALER_AUDITORDB_ProgressPointCoin *ppc) { struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (master_pub), @@ -2056,8 +2131,10 @@ postgres_insert_auditor_progress_coin (void *cls, static enum GNUNET_DB_QueryStatus postgres_update_auditor_progress_coin (void *cls, struct TALER_AUDITORDB_Session *session, - const struct TALER_MasterPublicKeyP *master_pub, - const struct TALER_AUDITORDB_ProgressPointCoin *ppc) + const struct + TALER_MasterPublicKeyP *master_pub, + const struct + TALER_AUDITORDB_ProgressPointCoin *ppc) { struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_uint64 (&ppc->last_withdraw_serial_id), @@ -2088,8 +2165,10 @@ postgres_update_auditor_progress_coin (void *cls, static enum GNUNET_DB_QueryStatus postgres_get_auditor_progress_coin (void *cls, struct TALER_AUDITORDB_Session *session, - const struct TALER_MasterPublicKeyP *master_pub, - struct TALER_AUDITORDB_ProgressPointCoin *ppc) + const struct + TALER_MasterPublicKeyP *master_pub, + struct TALER_AUDITORDB_ProgressPointCoin * + ppc) { struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (master_pub), @@ -2130,10 +2209,15 @@ postgres_get_auditor_progress_coin (void *cls, */ static enum GNUNET_DB_QueryStatus postgres_insert_wire_auditor_account_progress (void *cls, - struct TALER_AUDITORDB_Session *session, - const struct TALER_MasterPublicKeyP *master_pub, + struct TALER_AUDITORDB_Session * + session, + const struct + TALER_MasterPublicKeyP * + master_pub, const char *account_name, - const struct TALER_AUDITORDB_WireAccountProgressPoint *pp, + const struct + TALER_AUDITORDB_WireAccountProgressPoint + *pp, const void *in_wire_off, const void *out_wire_off, size_t wire_off_size) @@ -2168,10 +2252,15 @@ postgres_insert_wire_auditor_account_progress (void *cls, */ static enum GNUNET_DB_QueryStatus postgres_update_wire_auditor_account_progress (void *cls, - struct TALER_AUDITORDB_Session *session, - const struct TALER_MasterPublicKeyP *master_pub, + struct TALER_AUDITORDB_Session * + session, + const struct + TALER_MasterPublicKeyP * + master_pub, const char *account_name, - const struct TALER_AUDITORDB_WireAccountProgressPoint *pp, + const struct + TALER_AUDITORDB_WireAccountProgressPoint + *pp, const void *in_wire_off, const void *out_wire_off, size_t wire_off_size) @@ -2209,10 +2298,14 @@ postgres_update_wire_auditor_account_progress (void *cls, */ static enum GNUNET_DB_QueryStatus postgres_get_wire_auditor_account_progress (void *cls, - struct TALER_AUDITORDB_Session *session, - const struct TALER_MasterPublicKeyP *master_pub, + struct TALER_AUDITORDB_Session * + session, + const struct + TALER_MasterPublicKeyP *master_pub, const char *account_name, - struct TALER_AUDITORDB_WireAccountProgressPoint *pp, + struct + TALER_AUDITORDB_WireAccountProgressPoint + *pp, void **in_wire_off, void **out_wire_off, size_t *wire_off_size) @@ -2265,8 +2358,10 @@ postgres_get_wire_auditor_account_progress (void *cls, static enum GNUNET_DB_QueryStatus postgres_insert_wire_auditor_progress (void *cls, struct TALER_AUDITORDB_Session *session, - const struct TALER_MasterPublicKeyP *master_pub, - const struct TALER_AUDITORDB_WireProgressPoint *pp) + const struct + TALER_MasterPublicKeyP *master_pub, + const struct + TALER_AUDITORDB_WireProgressPoint *pp) { struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (master_pub), @@ -2293,8 +2388,10 @@ postgres_insert_wire_auditor_progress (void *cls, static enum GNUNET_DB_QueryStatus postgres_update_wire_auditor_progress (void *cls, struct TALER_AUDITORDB_Session *session, - const struct TALER_MasterPublicKeyP *master_pub, - const struct TALER_AUDITORDB_WireProgressPoint *pp) + const struct + TALER_MasterPublicKeyP *master_pub, + const struct + TALER_AUDITORDB_WireProgressPoint *pp) { struct GNUNET_PQ_QueryParam params[] = { TALER_PQ_query_param_absolute_time (&pp->last_timestamp), @@ -2320,7 +2417,8 @@ postgres_update_wire_auditor_progress (void *cls, static enum GNUNET_DB_QueryStatus postgres_get_wire_auditor_progress (void *cls, struct TALER_AUDITORDB_Session *session, - const struct TALER_MasterPublicKeyP *master_pub, + const struct + TALER_MasterPublicKeyP *master_pub, struct TALER_AUDITORDB_WireProgressPoint *pp) { struct GNUNET_PQ_QueryParam params[] = { @@ -2329,7 +2427,7 @@ postgres_get_wire_auditor_progress (void *cls, }; struct GNUNET_PQ_ResultSpec rs[] = { TALER_PQ_result_spec_absolute_time ("last_timestamp", - &pp->last_timestamp), + &pp->last_timestamp), GNUNET_PQ_result_spec_end }; @@ -2511,9 +2609,11 @@ postgres_get_reserve_info (void *cls, static enum GNUNET_DB_QueryStatus postgres_insert_reserve_summary (void *cls, struct TALER_AUDITORDB_Session *session, - const struct TALER_MasterPublicKeyP *master_pub, + const struct + TALER_MasterPublicKeyP *master_pub, const struct TALER_Amount *reserve_balance, - const struct TALER_Amount *withdraw_fee_balance) + const struct + TALER_Amount *withdraw_fee_balance) { struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (master_pub), @@ -2547,9 +2647,11 @@ postgres_insert_reserve_summary (void *cls, static enum GNUNET_DB_QueryStatus postgres_update_reserve_summary (void *cls, struct TALER_AUDITORDB_Session *session, - const struct TALER_MasterPublicKeyP *master_pub, + const struct + TALER_MasterPublicKeyP *master_pub, const struct TALER_Amount *reserve_balance, - const struct TALER_Amount *withdraw_fee_balance) + const struct + TALER_Amount *withdraw_fee_balance) { struct GNUNET_PQ_QueryParam params[] = { TALER_PQ_query_param_amount (reserve_balance), @@ -2614,7 +2716,8 @@ postgres_get_reserve_summary (void *cls, static enum GNUNET_DB_QueryStatus postgres_insert_wire_fee_summary (void *cls, struct TALER_AUDITORDB_Session *session, - const struct TALER_MasterPublicKeyP *master_pub, + const struct + TALER_MasterPublicKeyP *master_pub, const struct TALER_Amount *wire_fee_balance) { struct GNUNET_PQ_QueryParam params[] = { @@ -2642,7 +2745,8 @@ postgres_insert_wire_fee_summary (void *cls, static enum GNUNET_DB_QueryStatus postgres_update_wire_fee_summary (void *cls, struct TALER_AUDITORDB_Session *session, - const struct TALER_MasterPublicKeyP *master_pub, + const struct + TALER_MasterPublicKeyP *master_pub, const struct TALER_Amount *wire_fee_balance) { struct GNUNET_PQ_QueryParam params[] = { @@ -2706,7 +2810,8 @@ postgres_get_wire_fee_summary (void *cls, static enum GNUNET_DB_QueryStatus postgres_insert_denomination_balance (void *cls, struct TALER_AUDITORDB_Session *session, - const struct GNUNET_HashCode *denom_pub_hash, + const struct + GNUNET_HashCode *denom_pub_hash, const struct TALER_Amount *denom_balance, const struct TALER_Amount *denom_risk, const struct TALER_Amount *payback_loss, @@ -2743,7 +2848,8 @@ postgres_insert_denomination_balance (void *cls, static enum GNUNET_DB_QueryStatus postgres_update_denomination_balance (void *cls, struct TALER_AUDITORDB_Session *session, - const struct GNUNET_HashCode *denom_pub_hash, + const struct + GNUNET_HashCode *denom_pub_hash, const struct TALER_Amount *denom_balance, const struct TALER_Amount *denom_risk, const struct TALER_Amount *payback_loss, @@ -2823,7 +2929,8 @@ postgres_get_denomination_balance (void *cls, static enum GNUNET_DB_QueryStatus postgres_insert_balance_summary (void *cls, struct TALER_AUDITORDB_Session *session, - const struct TALER_MasterPublicKeyP *master_pub, + const struct + TALER_MasterPublicKeyP *master_pub, const struct TALER_Amount *denom_balance, const struct TALER_Amount *deposit_fee_balance, const struct TALER_Amount *melt_fee_balance, @@ -2878,7 +2985,8 @@ postgres_insert_balance_summary (void *cls, static enum GNUNET_DB_QueryStatus postgres_update_balance_summary (void *cls, struct TALER_AUDITORDB_Session *session, - const struct TALER_MasterPublicKeyP *master_pub, + const struct + TALER_MasterPublicKeyP *master_pub, const struct TALER_Amount *denom_balance, const struct TALER_Amount *deposit_fee_balance, const struct TALER_Amount *melt_fee_balance, @@ -2967,10 +3075,14 @@ postgres_get_balance_summary (void *cls, static enum GNUNET_DB_QueryStatus postgres_insert_historic_denom_revenue (void *cls, struct TALER_AUDITORDB_Session *session, - const struct TALER_MasterPublicKeyP *master_pub, - const struct GNUNET_HashCode *denom_pub_hash, - struct GNUNET_TIME_Absolute revenue_timestamp, - const struct TALER_Amount *revenue_balance, + const struct + TALER_MasterPublicKeyP *master_pub, + const struct + GNUNET_HashCode *denom_pub_hash, + struct GNUNET_TIME_Absolute + revenue_timestamp, + const struct + TALER_Amount *revenue_balance, const struct TALER_Amount *loss_balance) { struct GNUNET_PQ_QueryParam params[] = { @@ -2983,8 +3095,8 @@ postgres_insert_historic_denom_revenue (void *cls, }; return GNUNET_PQ_eval_prepared_non_select (session->conn, - "auditor_historic_denomination_revenue_insert", - params); + "auditor_historic_denomination_revenue_insert", + params); } @@ -3005,7 +3117,7 @@ struct HistoricDenomRevenueContext /** * Plugin context. - */ + */ struct PostgresClosure *pg; /** @@ -3031,7 +3143,7 @@ historic_denom_revenue_cb (void *cls, { struct HistoricDenomRevenueContext *hrc = cls; struct PostgresClosure *pg = hrc->pg; - + for (unsigned int i = 0; i < num_results; i++) { struct GNUNET_HashCode denom_pub_hash; @@ -3040,7 +3152,8 @@ historic_denom_revenue_cb (void *cls, struct TALER_Amount loss; struct GNUNET_PQ_ResultSpec rs[] = { GNUNET_PQ_result_spec_auto_from_type ("denom_pub_hash", &denom_pub_hash), - TALER_PQ_result_spec_absolute_time ("revenue_timestamp", &revenue_timestamp), + TALER_PQ_result_spec_absolute_time ("revenue_timestamp", + &revenue_timestamp), TALER_PQ_RESULT_SPEC_AMOUNT ("revenue_balance", &revenue_balance), TALER_PQ_RESULT_SPEC_AMOUNT ("loss_balance", &loss), GNUNET_PQ_result_spec_end @@ -3082,8 +3195,10 @@ historic_denom_revenue_cb (void *cls, static enum GNUNET_DB_QueryStatus postgres_select_historic_denom_revenue (void *cls, struct TALER_AUDITORDB_Session *session, - const struct TALER_MasterPublicKeyP *master_pub, - TALER_AUDITORDB_HistoricDenominationRevenueDataCallback cb, + const struct + TALER_MasterPublicKeyP *master_pub, + TALER_AUDITORDB_HistoricDenominationRevenueDataCallback + cb, void *cb_cls) { struct PostgresClosure *pg = cls; @@ -3122,11 +3237,15 @@ postgres_select_historic_denom_revenue (void *cls, */ static enum GNUNET_DB_QueryStatus postgres_insert_historic_reserve_revenue (void *cls, - struct TALER_AUDITORDB_Session *session, - const struct TALER_MasterPublicKeyP *master_pub, - struct GNUNET_TIME_Absolute start_time, + struct TALER_AUDITORDB_Session * + session, + const struct + TALER_MasterPublicKeyP *master_pub, + struct GNUNET_TIME_Absolute + start_time, struct GNUNET_TIME_Absolute end_time, - const struct TALER_Amount *reserve_profits) + const struct + TALER_Amount *reserve_profits) { struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (master_pub), @@ -3185,7 +3304,7 @@ historic_reserve_revenue_cb (void *cls, { struct HistoricReserveRevenueContext *hrc = cls; struct PostgresClosure *pg = hrc->pg; - + for (unsigned int i = 0; i < num_results; i++) { struct GNUNET_TIME_Absolute start_date; @@ -3200,8 +3319,8 @@ historic_reserve_revenue_cb (void *cls, if (GNUNET_OK != GNUNET_PQ_extract_result (result, - rs, - i)) + rs, + i)) { GNUNET_break (0); hrc->qs = GNUNET_DB_STATUS_HARD_ERROR; @@ -3230,9 +3349,12 @@ historic_reserve_revenue_cb (void *cls, */ static enum GNUNET_DB_QueryStatus postgres_select_historic_reserve_revenue (void *cls, - struct TALER_AUDITORDB_Session *session, - const struct TALER_MasterPublicKeyP *master_pub, - TALER_AUDITORDB_HistoricReserveRevenueDataCallback cb, + struct TALER_AUDITORDB_Session * + session, + const struct + TALER_MasterPublicKeyP *master_pub, + TALER_AUDITORDB_HistoricReserveRevenueDataCallback + cb, void *cb_cls) { struct PostgresClosure *pg = cls; @@ -3271,7 +3393,8 @@ postgres_select_historic_reserve_revenue (void *cls, static enum GNUNET_DB_QueryStatus postgres_insert_predicted_result (void *cls, struct TALER_AUDITORDB_Session *session, - const struct TALER_MasterPublicKeyP *master_pub, + const struct + TALER_MasterPublicKeyP *master_pub, const struct TALER_Amount *balance) { struct GNUNET_PQ_QueryParam params[] = { @@ -3299,7 +3422,8 @@ postgres_insert_predicted_result (void *cls, static enum GNUNET_DB_QueryStatus postgres_update_predicted_result (void *cls, struct TALER_AUDITORDB_Session *session, - const struct TALER_MasterPublicKeyP *master_pub, + const struct + TALER_MasterPublicKeyP *master_pub, const struct TALER_Amount *balance) { struct GNUNET_PQ_QueryParam params[] = { @@ -3423,21 +3547,32 @@ libtaler_plugin_auditordb_postgres_init (void *cls) plugin->insert_denomination_info = &postgres_insert_denomination_info; plugin->get_auditor_progress_reserve = &postgres_get_auditor_progress_reserve; - plugin->update_auditor_progress_reserve = &postgres_update_auditor_progress_reserve; - plugin->insert_auditor_progress_reserve = &postgres_insert_auditor_progress_reserve; - plugin->get_auditor_progress_aggregation = &postgres_get_auditor_progress_aggregation; - plugin->update_auditor_progress_aggregation = &postgres_update_auditor_progress_aggregation; - plugin->insert_auditor_progress_aggregation = &postgres_insert_auditor_progress_aggregation; - plugin->get_auditor_progress_deposit_confirmation = &postgres_get_auditor_progress_deposit_confirmation; - plugin->update_auditor_progress_deposit_confirmation = &postgres_update_auditor_progress_deposit_confirmation; - plugin->insert_auditor_progress_deposit_confirmation = &postgres_insert_auditor_progress_deposit_confirmation; + plugin->update_auditor_progress_reserve = + &postgres_update_auditor_progress_reserve; + plugin->insert_auditor_progress_reserve = + &postgres_insert_auditor_progress_reserve; + plugin->get_auditor_progress_aggregation = + &postgres_get_auditor_progress_aggregation; + plugin->update_auditor_progress_aggregation = + &postgres_update_auditor_progress_aggregation; + plugin->insert_auditor_progress_aggregation = + &postgres_insert_auditor_progress_aggregation; + plugin->get_auditor_progress_deposit_confirmation = + &postgres_get_auditor_progress_deposit_confirmation; + plugin->update_auditor_progress_deposit_confirmation = + &postgres_update_auditor_progress_deposit_confirmation; + plugin->insert_auditor_progress_deposit_confirmation = + &postgres_insert_auditor_progress_deposit_confirmation; plugin->get_auditor_progress_coin = &postgres_get_auditor_progress_coin; plugin->update_auditor_progress_coin = &postgres_update_auditor_progress_coin; plugin->insert_auditor_progress_coin = &postgres_insert_auditor_progress_coin; - plugin->get_wire_auditor_account_progress = &postgres_get_wire_auditor_account_progress; - plugin->update_wire_auditor_account_progress = &postgres_update_wire_auditor_account_progress; - plugin->insert_wire_auditor_account_progress = &postgres_insert_wire_auditor_account_progress; + plugin->get_wire_auditor_account_progress = + &postgres_get_wire_auditor_account_progress; + plugin->update_wire_auditor_account_progress = + &postgres_update_wire_auditor_account_progress; + plugin->insert_wire_auditor_account_progress = + &postgres_insert_wire_auditor_account_progress; plugin->get_wire_auditor_progress = &postgres_get_wire_auditor_progress; plugin->update_wire_auditor_progress = &postgres_update_wire_auditor_progress; plugin->insert_wire_auditor_progress = &postgres_insert_wire_auditor_progress; @@ -3463,11 +3598,15 @@ libtaler_plugin_auditordb_postgres_init (void *cls) plugin->update_balance_summary = &postgres_update_balance_summary; plugin->insert_balance_summary = &postgres_insert_balance_summary; - plugin->select_historic_denom_revenue = &postgres_select_historic_denom_revenue; - plugin->insert_historic_denom_revenue = &postgres_insert_historic_denom_revenue; + plugin->select_historic_denom_revenue = + &postgres_select_historic_denom_revenue; + plugin->insert_historic_denom_revenue = + &postgres_insert_historic_denom_revenue; - plugin->select_historic_reserve_revenue = &postgres_select_historic_reserve_revenue; - plugin->insert_historic_reserve_revenue = &postgres_insert_historic_reserve_revenue; + plugin->select_historic_reserve_revenue = + &postgres_select_historic_reserve_revenue; + plugin->insert_historic_reserve_revenue = + &postgres_insert_historic_reserve_revenue; plugin->get_predicted_balance = &postgres_get_predicted_balance; plugin->update_predicted_result = &postgres_update_predicted_result; diff --git a/src/auditordb/test_auditordb.c b/src/auditordb/test_auditordb.c index 68aa4564e..8f226266a 100644 --- a/src/auditordb/test_auditordb.c +++ b/src/auditordb/test_auditordb.c @@ -33,10 +33,10 @@ static int result = -1; * Report line of error if @a cond is true, and jump to label "drop". */ #define FAILIF(cond) \ - do { \ - if (!(cond)){ break;} \ - GNUNET_break (0); \ - goto drop; \ + do { \ + if (! (cond)) { break;} \ + GNUNET_break (0); \ + goto drop; \ } while (0) @@ -66,7 +66,8 @@ static struct TALER_AUDITORDB_Plugin *plugin; static int select_denomination_info_result (void *cls, - const struct TALER_DenominationKeyValidityPS *issue2) + const struct + TALER_DenominationKeyValidityPS *issue2) { const struct TALER_DenominationKeyValidityPS *issue1 = cls; @@ -159,26 +160,29 @@ run (void *cls) struct TALER_DenominationPublicKey denom_pub; struct GNUNET_HashCode denom_pub_hash; denom_priv.rsa_private_key = GNUNET_CRYPTO_rsa_private_key_create (1024); - denom_pub.rsa_public_key = GNUNET_CRYPTO_rsa_private_key_get_public (denom_priv.rsa_private_key); + denom_pub.rsa_public_key = GNUNET_CRYPTO_rsa_private_key_get_public ( + denom_priv.rsa_private_key); GNUNET_CRYPTO_rsa_public_key_hash (denom_pub.rsa_public_key, &denom_pub_hash); struct GNUNET_TIME_Absolute now, past, future, date; now = GNUNET_TIME_absolute_get (); (void) GNUNET_TIME_round_abs (&now); past = GNUNET_TIME_absolute_subtract (now, - GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_HOURS, - 4)); + GNUNET_TIME_relative_multiply ( + GNUNET_TIME_UNIT_HOURS, + 4)); future = GNUNET_TIME_absolute_add (now, - GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_HOURS, - 4)); + GNUNET_TIME_relative_multiply ( + GNUNET_TIME_UNIT_HOURS, + 4)); GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Test: auditor_insert_exchange\n"); FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != - plugin->insert_exchange (plugin->cls, - session, - &master_pub, - "https://exchange/")); + plugin->insert_exchange (plugin->cls, + session, + &master_pub, + "https://exchange/")); GNUNET_log (GNUNET_ERROR_TYPE_INFO, @@ -190,16 +194,18 @@ run (void *cls) issue.start = GNUNET_TIME_absolute_hton (now); issue.expire_withdraw = GNUNET_TIME_absolute_hton - (GNUNET_TIME_absolute_add (now, - GNUNET_TIME_UNIT_HOURS)); + (GNUNET_TIME_absolute_add (now, + GNUNET_TIME_UNIT_HOURS)); issue.expire_deposit = GNUNET_TIME_absolute_hton - (GNUNET_TIME_absolute_add - (now, - GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_HOURS, 2))); + (GNUNET_TIME_absolute_add + (now, + GNUNET_TIME_relative_multiply ( + GNUNET_TIME_UNIT_HOURS, 2))); issue.expire_legal = GNUNET_TIME_absolute_hton - (GNUNET_TIME_absolute_add - (now, - GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_HOURS, 3))); + (GNUNET_TIME_absolute_add + (now, + GNUNET_TIME_relative_multiply ( + GNUNET_TIME_UNIT_HOURS, 3))); TALER_amount_hton (&issue.value, &value); TALER_amount_hton (&issue.fee_withdraw, &fee_withdraw); TALER_amount_hton (&issue.fee_deposit, &fee_deposit); @@ -318,7 +324,8 @@ run (void *cls) FAILIF (0 != GNUNET_memcmp (&date, &future) || 0 != GNUNET_memcmp (&reserve_balance2, &reserve_balance) - || 0 != GNUNET_memcmp (&withdraw_fee_balance2, &withdraw_fee_balance)); + || 0 != GNUNET_memcmp (&withdraw_fee_balance2, + &withdraw_fee_balance)); GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Test: insert_reserve_summary\n"); @@ -355,8 +362,8 @@ run (void *cls) FAILIF ( (0 != GNUNET_memcmp (&reserve_balance2, &reserve_balance) || - (0 != GNUNET_memcmp (&withdraw_fee_balance2, - &withdraw_fee_balance)) ) ); + (0 != GNUNET_memcmp (&withdraw_fee_balance2, + &withdraw_fee_balance)) ) ); GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Test: insert_denomination_balance\n"); @@ -476,23 +483,23 @@ run (void *cls) FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != plugin->get_balance_summary (plugin->cls, - session, - &master_pub, - &denom_balance2, - &deposit_fee_balance2, - &melt_fee_balance2, - &refund_fee_balance2, - &rbalance2, - &loss2)); + session, + &master_pub, + &denom_balance2, + &deposit_fee_balance2, + &melt_fee_balance2, + &refund_fee_balance2, + &rbalance2, + &loss2)); FAILIF ( (0 != GNUNET_memcmp (&denom_balance2, &denom_balance) ) || - (0 != GNUNET_memcmp (&deposit_fee_balance2, - &deposit_fee_balance) ) || - (0 != GNUNET_memcmp (&melt_fee_balance2, - &melt_fee_balance) ) || - (0 != GNUNET_memcmp (&refund_fee_balance2, - &refund_fee_balance)) ); + (0 != GNUNET_memcmp (&deposit_fee_balance2, + &deposit_fee_balance) ) || + (0 != GNUNET_memcmp (&melt_fee_balance2, + &melt_fee_balance) ) || + (0 != GNUNET_memcmp (&refund_fee_balance2, + &refund_fee_balance)) ); FAILIF (0 != GNUNET_memcmp (&rbalance2, &rbalance)); FAILIF (0 != GNUNET_memcmp (&loss2, @@ -525,9 +532,12 @@ run (void *cls) int select_historic_denom_revenue_result (void *cls, - const struct GNUNET_HashCode *denom_pub_hash2, - struct GNUNET_TIME_Absolute revenue_timestamp2, - const struct TALER_Amount *revenue_balance2, + const struct + GNUNET_HashCode *denom_pub_hash2, + struct GNUNET_TIME_Absolute + revenue_timestamp2, + const struct + TALER_Amount *revenue_balance2, const struct TALER_Amount *loss2) { static int n = 0; @@ -535,19 +545,19 @@ run (void *cls) GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "select_historic_denom_revenue_result: row %u\n", n); - if (2 <= n++ - || cls != NULL - || (0 != GNUNET_memcmp (&revenue_timestamp2, &past) - && 0 != GNUNET_memcmp (&revenue_timestamp2, &now)) - || (0 != GNUNET_memcmp (denom_pub_hash2, &denom_pub_hash) - && 0 != GNUNET_memcmp (denom_pub_hash2, &rnd_hash)) - || 0 != GNUNET_memcmp (revenue_balance2, &rbalance) - || 0 != GNUNET_memcmp (loss2, &loss)) + if ((2 <= n++) + || (cls != NULL) + || ((0 != GNUNET_memcmp (&revenue_timestamp2, &past)) + && (0 != GNUNET_memcmp (&revenue_timestamp2, &now))) + || ((0 != GNUNET_memcmp (denom_pub_hash2, &denom_pub_hash)) + && (0 != GNUNET_memcmp (denom_pub_hash2, &rnd_hash))) + || (0 != GNUNET_memcmp (revenue_balance2, &rbalance)) + || (0 != GNUNET_memcmp (loss2, &loss))) { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "select_historic_denom_revenue_result: result does not match\n"); - GNUNET_break (0); - return GNUNET_SYSERR; + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "select_historic_denom_revenue_result: result does not match\n"); + GNUNET_break (0); + return GNUNET_SYSERR; } return GNUNET_OK; } @@ -556,7 +566,8 @@ run (void *cls) plugin->select_historic_denom_revenue (plugin->cls, session, &master_pub, - &select_historic_denom_revenue_result, + & + select_historic_denom_revenue_result, NULL)); GNUNET_log (GNUNET_ERROR_TYPE_INFO, @@ -588,26 +599,28 @@ run (void *cls) int select_historic_reserve_revenue_result (void *cls, - struct GNUNET_TIME_Absolute start_time2, + struct GNUNET_TIME_Absolute + start_time2, struct GNUNET_TIME_Absolute end_time2, - const struct TALER_Amount *reserve_profits2) + const struct + TALER_Amount *reserve_profits2) { static int n = 0; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "select_historic_reserve_revenue_result: row %u\n", n); - if (2 <= n++ - || cls != NULL - || (0 != GNUNET_memcmp (&start_time2, &past) - && 0 != GNUNET_memcmp (&start_time2, &now)) - || 0 != GNUNET_memcmp (&end_time2, &future) - || 0 != GNUNET_memcmp (reserve_profits2, &reserve_profits)) + if ((2 <= n++) + || (cls != NULL) + || ((0 != GNUNET_memcmp (&start_time2, &past)) + && (0 != GNUNET_memcmp (&start_time2, &now))) + || (0 != GNUNET_memcmp (&end_time2, &future)) + || (0 != GNUNET_memcmp (reserve_profits2, &reserve_profits))) { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "select_historic_reserve_revenue_result: result does not match\n"); - GNUNET_break (0); - return GNUNET_SYSERR; + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "select_historic_reserve_revenue_result: result does not match\n"); + GNUNET_break (0); + return GNUNET_SYSERR; } return GNUNET_OK; } @@ -700,7 +713,7 @@ run (void *cls) result = 0; -drop: + drop: if (NULL != session) { plugin->rollback (plugin->cls, @@ -721,7 +734,7 @@ drop: GNUNET_break (GNUNET_OK == plugin->drop_tables (plugin->cls, GNUNET_YES)); - unload: + unload: TALER_AUDITORDB_plugin_unload (plugin); plugin = NULL; } diff --git a/src/bank-lib/bank_api_admin.c b/src/bank-lib/bank_api_admin.c index 4a66d3293..72b1d773e 100644 --- a/src/bank-lib/bank_api_admin.c +++ b/src/bank-lib/bank_api_admin.c @@ -94,7 +94,7 @@ handle_admin_add_incoming_finished (void *cls, &row_id), GNUNET_JSON_spec_absolute_time ("timestamp", ×tamp), - GNUNET_JSON_spec_end() + GNUNET_JSON_spec_end () }; if (GNUNET_OK != @@ -217,8 +217,8 @@ TALER_BANK_admin_add_incoming (struct GNUNET_CURL_Context *ctx, GNUNET_assert (NULL != (aai->post_ctx.headers = curl_slist_append - (aai->post_ctx.headers, - "Content-Type: application/json"))); + (aai->post_ctx.headers, + "Content-Type: application/json"))); eh = curl_easy_init (); @@ -248,7 +248,8 @@ TALER_BANK_admin_add_incoming (struct GNUNET_CURL_Context *ctx, * @param aai the admin add incoming request handle */ void -TALER_BANK_admin_add_incoming_cancel (struct TALER_BANK_AdminAddIncomingHandle *aai) +TALER_BANK_admin_add_incoming_cancel (struct + TALER_BANK_AdminAddIncomingHandle *aai) { if (NULL != aai->job) { diff --git a/src/bank-lib/bank_api_common.c b/src/bank-lib/bank_api_common.c index ad1160073..50769dae2 100644 --- a/src/bank-lib/bank_api_common.c +++ b/src/bank-lib/bank_api_common.c @@ -130,7 +130,7 @@ TALER_BANK_parse_ec_ (const json_t *json) struct GNUNET_JSON_Specification spec[] = { GNUNET_JSON_spec_uint32 ("ec", &ec), - GNUNET_JSON_spec_end() + GNUNET_JSON_spec_end () }; if (GNUNET_OK != diff --git a/src/bank-lib/bank_api_history.c b/src/bank-lib/bank_api_history.c index 36e5724d0..6bc53cd50 100644 --- a/src/bank-lib/bank_api_history.c +++ b/src/bank-lib/bank_api_history.c @@ -88,7 +88,7 @@ parse_account_history (struct TALER_BANK_HistoryHandle *hh, GNUNET_break_op (0); return GNUNET_SYSERR; } - for (unsigned int i=0;ijson_enc = - json_dumps (reject_obj, - JSON_COMPACT))); + json_dumps (reject_obj, + JSON_COMPACT))); json_decref (reject_obj); GNUNET_assert (CURLE_OK == curl_easy_setopt (eh, diff --git a/src/bank-lib/fakebank.c b/src/bank-lib/fakebank.c index b6aee7f41..19c088d8b 100644 --- a/src/bank-lib/fakebank.c +++ b/src/bank-lib/fakebank.c @@ -30,7 +30,7 @@ /** * Maximum POST request size (for /admin/add/incoming) */ -#define REQUEST_BUFFER_MAX (4*1024) +#define REQUEST_BUFFER_MAX (4 * 1024) /** @@ -318,7 +318,7 @@ create_bank_error (struct MHD_Connection *connection, "ec", (json_int_t) ec); json_str = json_dumps (json, - JSON_INDENT(2)); + JSON_INDENT (2)); json_decref (json); if (NULL == json_str) { @@ -471,7 +471,7 @@ handle_admin_add_incoming (struct TALER_FAKEBANK_Handle *h, "timestamp", "/Date(0)/"); /*dummy tmp */ json_str = json_dumps (json, - JSON_INDENT(2)); + JSON_INDENT (2)); json_decref (json); if (NULL == json_str) { @@ -574,10 +574,10 @@ handle_reject (struct TALER_FAKEBANK_Handle *h, if (GNUNET_OK != found) return create_bank_error - (connection, - MHD_HTTP_NOT_FOUND, - TALER_EC_BANK_REJECT_TRANSACTION_NOT_FOUND, - "transaction unknown"); + (connection, + MHD_HTTP_NOT_FOUND, + TALER_EC_BANK_REJECT_TRANSACTION_NOT_FOUND, + "transaction unknown"); /* finally build regular response */ resp = MHD_create_response_from_buffer (0, NULL, @@ -608,9 +608,9 @@ handle_home_page (struct TALER_FAKEBANK_Handle *h, #define HELLOMSG "Hello, Fakebank!" resp = MHD_create_response_from_buffer - (strlen (HELLOMSG), - HELLOMSG, - MHD_RESPMEM_MUST_COPY); + (strlen (HELLOMSG), + HELLOMSG, + MHD_RESPMEM_MUST_COPY); ret = MHD_queue_response (connection, MHD_HTTP_OK, @@ -654,11 +654,11 @@ handle_history (struct TALER_FAKEBANK_Handle *h, MHD_GET_ARGUMENT_KIND, "delta"); if ( ((NULL != start) && (1 != sscanf (start, - "%llu", - &hri.start))) || - (NULL == delta) || (1 != sscanf (delta, - "%lld", - &hri.count)) ) + "%llu", + &hri.start))) || + (NULL == delta) || (1 != sscanf (delta, + "%lld", + &hri.count)) ) { GNUNET_break (0); return MHD_NO; @@ -667,7 +667,7 @@ handle_history (struct TALER_FAKEBANK_Handle *h, if (NULL == start) pos = 0 > hri.count ? - h->transactions_tail : h->transactions_head; + h->transactions_tail : h->transactions_head; else if (NULL != h->transactions_head) { @@ -728,7 +728,7 @@ handle_history_range (struct TALER_FAKEBANK_Handle *h, struct Transaction *pos; if (GNUNET_OK != TFH_parse_history_common_args (connection, - &ha)) + &ha)) { GNUNET_break (0); return MHD_NO; @@ -743,9 +743,9 @@ handle_history_range (struct TALER_FAKEBANK_Handle *h, if ( (NULL == start) || (1 != sscanf (start, "%llu", &start_stamp)) || - (NULL == end) || (1 != sscanf (end, - "%lld", - &end_stamp)) ) + (NULL == end) || (1 != sscanf (end, + "%lld", + &end_stamp)) ) { GNUNET_break (0); return MHD_NO; @@ -875,7 +875,7 @@ schedule_httpd (struct TALER_FAKEBANK_Handle *h) struct GNUNET_TIME_Relative tv; haveto = MHD_get_timeout (h->mhd_bank, - &timeout); + &timeout); if (MHD_YES == haveto) tv.rel_value_us = (uint64_t) timeout * 1000LL; else @@ -884,9 +884,9 @@ schedule_httpd (struct TALER_FAKEBANK_Handle *h) GNUNET_SCHEDULER_cancel (h->mhd_task); h->mhd_task = GNUNET_SCHEDULER_add_read_net (tv, - h->mhd_rfd, - &run_mhd, - h); + h->mhd_rfd, + &run_mhd, + h); } #else /** @@ -981,17 +981,18 @@ TALER_FAKEBANK_start (uint16_t port) h = GNUNET_new (struct TALER_FAKEBANK_Handle); h->mhd_bank = MHD_start_daemon (MHD_USE_DEBUG #if EPOLL_SUPPORT - | MHD_USE_EPOLL_INTERNAL_THREAD + | MHD_USE_EPOLL_INTERNAL_THREAD #else | MHD_USE_INTERNAL_POLLING_THREAD #endif - | MHD_USE_DUAL_STACK, + | MHD_USE_DUAL_STACK, port, NULL, NULL, &handle_mhd_request, h, MHD_OPTION_NOTIFY_COMPLETED, &handle_mhd_completion_callback, h, - MHD_OPTION_LISTEN_BACKLOG_SIZE, (unsigned int) 1024, + MHD_OPTION_LISTEN_BACKLOG_SIZE, (unsigned + int) 1024, MHD_OPTION_END); if (NULL == h->mhd_bank) { @@ -1000,7 +1001,7 @@ TALER_FAKEBANK_start (uint16_t port) } #if EPOLL_SUPPORT h->mhd_fd = MHD_get_daemon_info (h->mhd_bank, - MHD_DAEMON_INFO_EPOLL_FD)->epoll_fd; + MHD_DAEMON_INFO_EPOLL_FD)->epoll_fd; h->mhd_rfd = GNUNET_NETWORK_socket_box_native (h->mhd_fd); #endif schedule_httpd (h); diff --git a/src/bank-lib/fakebank.h b/src/bank-lib/fakebank.h index ff8ea7165..321bc1336 100644 --- a/src/bank-lib/fakebank.h +++ b/src/bank-lib/fakebank.h @@ -198,27 +198,24 @@ struct HistoryArgs * @param pos current position. * @return GNUNET_YES if the iteration shuold go on. */ -typedef int (*CheckAdvance) - (const struct HistoryArgs *ha, - const struct Transaction *pos); +typedef int (*CheckAdvance)(const struct HistoryArgs *ha, + const struct Transaction *pos); /** * Type for a function that steps over the next element * in the list of all transactions, after the current @a pos * _got_ included in the result. */ -typedef struct Transaction * (*Step) - (const struct HistoryArgs *ha, - const struct Transaction *pos); +typedef struct Transaction * (*Step)(const struct HistoryArgs *ha, + const struct Transaction *pos); /* * Type for a function that steps over the next element * in the list of all transactions, after the current @a pos * did _not_ get included in the result. */ -typedef struct Transaction * (*Skip) - (const struct HistoryArgs *ha, - const struct Transaction *pos); +typedef struct Transaction * (*Skip)(const struct HistoryArgs *ha, + const struct Transaction *pos); /** * Actual history response builder. diff --git a/src/bank-lib/fakebank_history.c b/src/bank-lib/fakebank_history.c index 4cd0dc4cd..b1770bb85 100644 --- a/src/bank-lib/fakebank_history.c +++ b/src/bank-lib/fakebank_history.c @@ -110,7 +110,7 @@ TFH_handle_history_range_advance (const struct HistoryArgs *ha, const struct HistoryRangeDates *hrd = ha->range; if ( (NULL != pos) && - (pos->date.abs_value_us <= hrd->end.abs_value_us) ) + (pos->date.abs_value_us <= hrd->end.abs_value_us) ) return GNUNET_YES; return GNUNET_NO; @@ -196,16 +196,16 @@ TFH_build_history_response (struct MHD_Connection *connection, ? (pos->rejected ? "cancel-" : "-") : (pos->rejected ? "cancel+" : "+"); trans = json_pack - ("{s:I, s:o, s:o, s:s, s:I, s:s}", - "row_id", (json_int_t) pos->row_id, - "date", GNUNET_JSON_from_time_abs (pos->date), - "amount", TALER_JSON_from_amount (&pos->amount), - "sign", sign, - "counterpart", (json_int_t) - ( (ha->account_number == pos->debit_account) - ? pos->credit_account - : pos->debit_account), - "wt_subject", subject); + ("{s:I, s:o, s:o, s:s, s:I, s:s}", + "row_id", (json_int_t) pos->row_id, + "date", GNUNET_JSON_from_time_abs (pos->date), + "amount", TALER_JSON_from_amount (&pos->amount), + "sign", sign, + "counterpart", (json_int_t) + ( (ha->account_number == pos->debit_account) + ? pos->credit_account + : pos->debit_account), + "wt_subject", subject); GNUNET_assert (NULL != trans); GNUNET_free (subject); @@ -244,9 +244,9 @@ TFH_build_history_response (struct MHD_Connection *connection, GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Returning empty transaction history\n"); resp = MHD_create_response_from_buffer - (0, - "", - MHD_RESPMEM_PERSISTENT); + (0, + "", + MHD_RESPMEM_PERSISTENT); ret = MHD_queue_response (connection, MHD_HTTP_NO_CONTENT, resp); @@ -270,7 +270,7 @@ TFH_build_history_response (struct MHD_Connection *connection, size_t json_len; json_str = json_dumps (jresponse, - JSON_INDENT(2)); + JSON_INDENT (2)); json_decref (jresponse); if (NULL == json_str) { @@ -339,9 +339,9 @@ TFH_parse_history_common_args (struct MHD_Connection *connection, MHD_GET_ARGUMENT_KIND, "ordering"); account_number = MHD_lookup_connection_value - (connection, - MHD_GET_ARGUMENT_KIND, - "account_number"); + (connection, + MHD_GET_ARGUMENT_KIND, + "account_number"); /* Fail if one of the above failed. */ if ( (NULL == direction) || @@ -356,11 +356,11 @@ TFH_parse_history_common_args (struct MHD_Connection *connection, "CREDIT")) && (0 != strcasecmp (direction, "DEBIT")) ) || - (1 != sscanf (account_number, - "%llu", - &ha->account_number)) || - ( (NULL == auth) || (0 != strcasecmp (auth, - "basic")) ) ) + (1 != sscanf (account_number, + "%llu", + &ha->account_number)) || + ( (NULL == auth) || (0 != strcasecmp (auth, + "basic")) ) ) { /* Invalid request, given that this is fakebank we impolitely * just kill the connection instead of returning a nice error. @@ -396,8 +396,9 @@ TFH_parse_history_common_args (struct MHD_Connection *connection, "OMIT")) { /* nothing */ - } else if (0 == strcasecmp (cancelled, - "SHOW")) + } + else if (0 == strcasecmp (cancelled, + "SHOW")) { ha->direction |= TALER_BANK_DIRECTION_CANCEL; } @@ -410,8 +411,8 @@ TFH_parse_history_common_args (struct MHD_Connection *connection, } if ((NULL != ordering) - && 0 == strcmp ("ascending", - ordering)) + && (0 == strcmp ("ascending", + ordering))) ha->ascending = GNUNET_YES; else ha->ascending = GNUNET_NO; diff --git a/src/bank-lib/taler-bank-transfer.c b/src/bank-lib/taler-bank-transfer.c index 2729b7ee9..6297d6502 100644 --- a/src/bank-lib/taler-bank-transfer.c +++ b/src/bank-lib/taler-bank-transfer.c @@ -203,48 +203,48 @@ main (int argc, char *const *argv) { const struct GNUNET_GETOPT_CommandLineOption options[] = { GNUNET_GETOPT_option_mandatory - (TALER_getopt_get_amount ('a', - "amount", - "VALUE", - "value to transfer", - &amount)), + (TALER_getopt_get_amount ('a', + "amount", + "VALUE", + "value to transfer", + &amount)), GNUNET_GETOPT_option_mandatory - (GNUNET_GETOPT_option_string ('b', - "bank", - "URL", - "base URL of the bank", - &bank_url)), + (GNUNET_GETOPT_option_string ('b', + "bank", + "URL", + "base URL of the bank", + &bank_url)), GNUNET_GETOPT_option_help ("Deposit funds into a Taler reserve"), GNUNET_GETOPT_option_mandatory - (GNUNET_GETOPT_option_ulong ('C', - "credit", - "ACCOUNT", - "number of the bank account to credit", - &credit_account_no)), + (GNUNET_GETOPT_option_ulong ('C', + "credit", + "ACCOUNT", + "number of the bank account to credit", + &credit_account_no)), GNUNET_GETOPT_option_mandatory - (GNUNET_GETOPT_option_ulong ('D', - "debit", - "ACCOUNT", - "number of the bank account to debit", - &debit_account_no)), + (GNUNET_GETOPT_option_ulong ('D', + "debit", + "ACCOUNT", + "number of the bank account to debit", + &debit_account_no)), GNUNET_GETOPT_option_mandatory - (GNUNET_GETOPT_option_string ('s', - "subject", - "STRING", - "specifies the wire transfer subject", - &subject)), + (GNUNET_GETOPT_option_string ('s', + "subject", + "STRING", + "specifies the wire transfer subject", + &subject)), GNUNET_GETOPT_option_mandatory - (GNUNET_GETOPT_option_string ('u', - "user", - "USERNAME", - "username to use for authentication", - &username)), + (GNUNET_GETOPT_option_string ('u', + "user", + "USERNAME", + "username to use for authentication", + &username)), GNUNET_GETOPT_option_mandatory - (GNUNET_GETOPT_option_string ('p', - "pass", - "PASSPHRASE", - "passphrase to use for authentication", - &password)), + (GNUNET_GETOPT_option_string ('p', + "pass", + "PASSPHRASE", + "passphrase to use for authentication", + &password)), GNUNET_GETOPT_OPTION_END }; @@ -256,9 +256,9 @@ main (int argc, char *const *argv) if (GNUNET_OK != GNUNET_PROGRAM_run (argc, argv, "taler-bank-transfer", - "Execute bank transfer", - options, - &run, NULL)) + "Execute bank transfer", + options, + &run, NULL)) return 1; return global_ret; } diff --git a/src/bank-lib/taler-fakebank-run.c b/src/bank-lib/taler-fakebank-run.c index 599ca85d6..51d054bca 100644 --- a/src/bank-lib/taler-fakebank-run.c +++ b/src/bank-lib/taler-fakebank-run.c @@ -65,13 +65,13 @@ main (int argc, const struct GNUNET_GETOPT_CommandLineOption options[] = { GNUNET_GETOPT_OPTION_END }; - + if (GNUNET_OK != GNUNET_PROGRAM_run (argc, argv, "taler-fakebank-run", - "Runs the fakebank", - options, - &run, + "Runs the fakebank", + options, + &run, NULL)) return 1; diff --git a/src/bank-lib/test_bank_api.c b/src/bank-lib/test_bank_api.c index b1b943771..043234560 100644 --- a/src/bank-lib/test_bank_api.c +++ b/src/bank-lib/test_bank_api.c @@ -41,8 +41,7 @@ static void run (void *cls) { int *resultp = cls; - static struct TBI_Command commands[] = - { + static struct TBI_Command commands[] = { /* Ask complete history of 'Exchange' user (number 2) */ { .oc = TBI_OC_HISTORY, .label = "history-0", @@ -113,7 +112,8 @@ run (void *cls) { .oc = TBI_OC_HISTORY, .label = "history-r3", .details.history.account_number = 2, - .details.history.direction = TALER_BANK_DIRECTION_BOTH | TALER_BANK_DIRECTION_CANCEL, + .details.history.direction = TALER_BANK_DIRECTION_BOTH + | TALER_BANK_DIRECTION_CANCEL, .details.history.start_row_ref = NULL, .details.history.num_results = 5 }, { .oc = TBI_OC_END } @@ -133,7 +133,7 @@ run (void *cls) */ int main (int argc, - char * const *argv) + char *const *argv) { struct GNUNET_OS_Process *bankd; unsigned int cnt; @@ -143,11 +143,11 @@ main (int argc, if (GNUNET_OK != GNUNET_NETWORK_test_port_free (IPPROTO_TCP, - 8081)) + 8081)) { fprintf (stderr, "Required port %u not available, skipping.\n", - 8081); + 8081); return 77; } GNUNET_log_setup ("test-bank-api", @@ -157,13 +157,14 @@ main (int argc, if (NULL == (dbconn = getenv ("TALER_EXCHANGEDB_POSTGRES_CONFIG"))) dbconn = defaultdb; char *purgedb_cmd; - GNUNET_asprintf (&purgedb_cmd, "taler-bank-manage -c bank.conf --with-db=%s django flush --no-input", + GNUNET_asprintf (&purgedb_cmd, + "taler-bank-manage -c bank.conf --with-db=%s django flush --no-input", dbconn); if (0 != system (purgedb_cmd)) { - fprintf (stderr, - "Could not purge database\n"); - return 77; + fprintf (stderr, + "Could not purge database\n"); + return 77; } bankd = GNUNET_OS_start_process (GNUNET_NO, @@ -188,14 +189,15 @@ main (int argc, "Waiting for taler-bank-manage to be ready\n"); cnt = 0; do - { - fprintf (stderr, "."); - sleep (1); - cnt++; - if (cnt > 30) - break; - } - while (0 != system ("wget -q -t 1 -T 1 http://127.0.0.1:8080/ -o /dev/null -O /dev/null")); + { + fprintf (stderr, "."); + sleep (1); + cnt++; + if (cnt > 30) + break; + } + while (0 != system ( + "wget -q -t 1 -T 1 http://127.0.0.1:8080/ -o /dev/null -O /dev/null")); fprintf (stderr, "\n"); diff --git a/src/bank-lib/test_bank_api_new.c b/src/bank-lib/test_bank_api_new.c index 4a89c1931..17acac9bc 100644 --- a/src/bank-lib/test_bank_api_new.c +++ b/src/bank-lib/test_bank_api_new.c @@ -49,8 +49,8 @@ #define ADDSECS(base, secs) \ GNUNET_TIME_absolute_add \ (base, \ - GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, \ - secs)) + GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, \ + secs)) /** * Subtract seconds. * @@ -61,8 +61,8 @@ #define SUBSECS(base, secs) \ GNUNET_TIME_absolute_subtract \ (base, \ - GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, \ - secs)) + GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, \ + secs)) /** * Bank process. */ @@ -96,35 +96,35 @@ run (void *cls, 5), TALER_TESTING_cmd_bank_history_range_with_dates ("history-0-range", - bank_url, - EXCHANGE_ACCOUNT_NUMBER, - TALER_BANK_DIRECTION_BOTH, - GNUNET_NO, - SUBSECS (now, - 5), - ADDSECS (now, - 5)), + bank_url, + EXCHANGE_ACCOUNT_NUMBER, + TALER_BANK_DIRECTION_BOTH, + GNUNET_NO, + SUBSECS (now, + 5), + ADDSECS (now, + 5)), TALER_TESTING_cmd_fakebank_transfer_with_subject ("deposit-1", - "KUDOS:5.01", - bank_url, - BANK_ACCOUNT_NUMBER, - EXCHANGE_ACCOUNT_NUMBER, - AUTHS[BANK_ACCOUNT_NUMBER -1].details.basic.username, - AUTHS[BANK_ACCOUNT_NUMBER -1].details.basic.password, - "subject 1", - "http://exchange.com/"), + "KUDOS:5.01", + bank_url, + BANK_ACCOUNT_NUMBER, + EXCHANGE_ACCOUNT_NUMBER, + AUTHS[BANK_ACCOUNT_NUMBER - 1].details.basic.username, + AUTHS[BANK_ACCOUNT_NUMBER - 1].details.basic.password, + "subject 1", + "http://exchange.com/"), /* bank gives to exchange */ TALER_TESTING_cmd_fakebank_transfer_with_subject ("deposit-2", - "KUDOS:5.01", - bank_url, - BANK_ACCOUNT_NUMBER, - EXCHANGE_ACCOUNT_NUMBER, - AUTHS[BANK_ACCOUNT_NUMBER -1].details.basic.username, - AUTHS[BANK_ACCOUNT_NUMBER -1].details.basic.password, - "subject 2", - "http://exchange.com/"), + "KUDOS:5.01", + bank_url, + BANK_ACCOUNT_NUMBER, + EXCHANGE_ACCOUNT_NUMBER, + AUTHS[BANK_ACCOUNT_NUMBER - 1].details.basic.username, + AUTHS[BANK_ACCOUNT_NUMBER - 1].details.basic.password, + "subject 2", + "http://exchange.com/"), TALER_TESTING_cmd_bank_history ("history-1c", bank_url, EXCHANGE_ACCOUNT_NUMBER, @@ -158,14 +158,14 @@ run (void *cls, */ TALER_TESTING_cmd_bank_history_range_with_dates ("history-2-range", - bank_url, - EXCHANGE_ACCOUNT_NUMBER, - TALER_BANK_DIRECTION_BOTH, - GNUNET_NO, - SUBSECS (now, - 50), - ADDSECS (now, - 5)), + bank_url, + EXCHANGE_ACCOUNT_NUMBER, + TALER_BANK_DIRECTION_BOTH, + GNUNET_NO, + SUBSECS (now, + 50), + ADDSECS (now, + 5)), TALER_TESTING_cmd_bank_reject ("reject-1", bank_url, "deposit-1"), @@ -182,8 +182,8 @@ run (void *cls, /* Pacifies "make check" */ int -main(int argc, - char * const *argv) +main (int argc, + char *const *argv) { unsigned int ret; /* These environment variables get in the way... */ @@ -192,11 +192,11 @@ main(int argc, GNUNET_log_setup ("test-bank-api-new", "DEBUG", NULL); if (NULL == - (bank_url = TALER_TESTING_prepare_bank (CONFIG_FILE))) + (bank_url = TALER_TESTING_prepare_bank (CONFIG_FILE))) return 77; if (NULL == (bankd = - TALER_TESTING_run_bank (CONFIG_FILE, bank_url))) + TALER_TESTING_run_bank (CONFIG_FILE, bank_url))) return 77; ret = TALER_TESTING_setup (&run, diff --git a/src/bank-lib/test_bank_api_twisted.c b/src/bank-lib/test_bank_api_twisted.c index 3bb149fda..a8f60c5eb 100644 --- a/src/bank-lib/test_bank_api_twisted.c +++ b/src/bank-lib/test_bank_api_twisted.c @@ -115,7 +115,7 @@ purge_process (struct GNUNET_OS_Process *process) int main (int argc, - char * const *argv) + char *const *argv) { unsigned int ret; /* These environment variables get in the way... */ @@ -127,19 +127,19 @@ main (int argc, NULL); if (NULL == (bank_url = TALER_TESTING_prepare_bank - (CONFIG_FILE))) + (CONFIG_FILE))) return 77; if (NULL == (bankd = TALER_TESTING_run_bank - (CONFIG_FILE, - bank_url))) + (CONFIG_FILE, + bank_url))) { GNUNET_free (bank_url); return 77; } if (NULL == (twister_url = TALER_TESTING_prepare_twister - (CONFIG_FILE))) + (CONFIG_FILE))) { purge_process (bankd); GNUNET_free (bank_url); diff --git a/src/bank-lib/test_bank_api_with_fakebank.c b/src/bank-lib/test_bank_api_with_fakebank.c index 5c940d789..331968120 100644 --- a/src/bank-lib/test_bank_api_with_fakebank.c +++ b/src/bank-lib/test_bank_api_with_fakebank.c @@ -37,8 +37,7 @@ static void run (void *cls) { int *resultp = cls; - static struct TBI_Command commands[] = - { + static struct TBI_Command commands[] = { { .oc = TBI_OC_HISTORY, .label = "history-0", .details.history.account_number = 1, @@ -134,7 +133,8 @@ run (void *cls) { .oc = TBI_OC_HISTORY, .label = "history-r1c", .details.history.account_number = 1, - .details.history.direction = TALER_BANK_DIRECTION_BOTH | TALER_BANK_DIRECTION_CANCEL, + .details.history.direction = TALER_BANK_DIRECTION_BOTH + | TALER_BANK_DIRECTION_CANCEL, .details.history.start_row_ref = NULL, .details.history.num_results = 5 }, { .oc = TBI_OC_EXPECT_TRANSFER, @@ -160,7 +160,7 @@ run (void *cls) */ int main (int argc, - char * const *argv) + char *const *argv) { int result; diff --git a/src/bank-lib/test_bank_api_with_fakebank_new.c b/src/bank-lib/test_bank_api_with_fakebank_new.c index 8865cc403..046248ad8 100644 --- a/src/bank-lib/test_bank_api_with_fakebank_new.c +++ b/src/bank-lib/test_bank_api_with_fakebank_new.c @@ -76,14 +76,14 @@ run (void *cls, * the parameters, although it was always set as '200 OK' */ TALER_TESTING_cmd_fakebank_transfer_with_subject ("debit-1", - "KUDOS:5.01", - fakebank_url, - EXCHANGE_ACCOUNT_NUMBER, - BANK_ACCOUNT_NUMBER, - AUTHS[EXCHANGE_ACCOUNT_NUMBER -1].details.basic.username, - AUTHS[EXCHANGE_ACCOUNT_NUMBER -1].details.basic.password, - "subject 1", - "http://exchange.com/"), + "KUDOS:5.01", + fakebank_url, + EXCHANGE_ACCOUNT_NUMBER, + BANK_ACCOUNT_NUMBER, + AUTHS[EXCHANGE_ACCOUNT_NUMBER - 1].details.basic.username, + AUTHS[EXCHANGE_ACCOUNT_NUMBER - 1].details.basic.password, + "subject 1", + "http://exchange.com/"), TALER_TESTING_cmd_bank_history ("history-1c", fakebank_url, @@ -103,25 +103,25 @@ run (void *cls, TALER_TESTING_cmd_fakebank_transfer_with_subject ("debit-2", - "KUDOS:3.21", - fakebank_url, - EXCHANGE_ACCOUNT_NUMBER, // debit account. - USER_ACCOUNT_NUMBER, - AUTHS[EXCHANGE_ACCOUNT_NUMBER -1].details.basic.username, - AUTHS[EXCHANGE_ACCOUNT_NUMBER -1].details.basic.password, - "subject 2", - "http://exchange.org/"), + "KUDOS:3.21", + fakebank_url, + EXCHANGE_ACCOUNT_NUMBER, // debit account. + USER_ACCOUNT_NUMBER, + AUTHS[EXCHANGE_ACCOUNT_NUMBER - 1].details.basic.username, + AUTHS[EXCHANGE_ACCOUNT_NUMBER - 1].details.basic.password, + "subject 2", + "http://exchange.org/"), TALER_TESTING_cmd_fakebank_transfer_with_subject ("credit-2", - "KUDOS:3.22", - fakebank_url, - USER_ACCOUNT_NUMBER, // debit account. - EXCHANGE_ACCOUNT_NUMBER, - AUTHS[USER_ACCOUNT_NUMBER -1].details.basic.username, - AUTHS[USER_ACCOUNT_NUMBER -1].details.basic.password, - "credit 2", - "http://exchange.org/"), + "KUDOS:3.22", + fakebank_url, + USER_ACCOUNT_NUMBER, // debit account. + EXCHANGE_ACCOUNT_NUMBER, + AUTHS[USER_ACCOUNT_NUMBER - 1].details.basic.username, + AUTHS[USER_ACCOUNT_NUMBER - 1].details.basic.password, + "credit 2", + "http://exchange.org/"), TALER_TESTING_cmd_bank_history ("history-2b", fakebank_url, @@ -152,18 +152,18 @@ run (void *cls, TALER_TESTING_cmd_fakebank_transfer_with_subject ("credit-for-reject-1", - "KUDOS:5.01", - fakebank_url, - BANK_ACCOUNT_NUMBER, - EXCHANGE_ACCOUNT_NUMBER, - AUTHS[BANK_ACCOUNT_NUMBER -1].details.basic.username, - AUTHS[BANK_ACCOUNT_NUMBER -1].details.basic.password, - "subject 3", - "http://exchange.net/"), - - TALER_TESTING_cmd_bank_reject ("reject-1", - fakebank_url, - "credit-for-reject-1"), + "KUDOS:5.01", + fakebank_url, + BANK_ACCOUNT_NUMBER, + EXCHANGE_ACCOUNT_NUMBER, + AUTHS[BANK_ACCOUNT_NUMBER - 1].details.basic.username, + AUTHS[BANK_ACCOUNT_NUMBER - 1].details.basic.password, + "subject 3", + "http://exchange.net/"), + + TALER_TESTING_cmd_bank_reject ("reject-1", + fakebank_url, + "credit-for-reject-1"), TALER_TESTING_cmd_bank_history ("history-r1", fakebank_url, @@ -176,15 +176,15 @@ run (void *cls, TALER_TESTING_cmd_bank_history ("history-r1c", fakebank_url, BANK_ACCOUNT_NUMBER, - TALER_BANK_DIRECTION_BOTH | - TALER_BANK_DIRECTION_CANCEL, + TALER_BANK_DIRECTION_BOTH + | TALER_BANK_DIRECTION_CANCEL, GNUNET_YES, NULL, 5), TALER_TESTING_cmd_check_bank_transfer_with_ref ("expect-credit-reject-1", - "credit-for-reject-1"), + "credit-for-reject-1"), TALER_TESTING_cmd_check_bank_empty ("expect-empty-2"), @@ -202,7 +202,7 @@ run (void *cls, int main (int argc, - char * const *argv) + char *const *argv) { /* These environment variables get in the way... */ unsetenv ("XDG_DATA_HOME"); diff --git a/src/bank-lib/test_bank_api_with_fakebank_twisted.c b/src/bank-lib/test_bank_api_with_fakebank_twisted.c index 162eb5dfe..8c5b90a1a 100644 --- a/src/bank-lib/test_bank_api_with_fakebank_twisted.c +++ b/src/bank-lib/test_bank_api_with_fakebank_twisted.c @@ -115,7 +115,7 @@ purge_process (struct GNUNET_OS_Process *process) int main (int argc, - char * const *argv) + char *const *argv) { unsigned int ret; @@ -128,12 +128,12 @@ main (int argc, NULL); if (NULL == (fakebank_url = TALER_TESTING_prepare_fakebank - (CONFIG_FILE, - "account-1"))) + (CONFIG_FILE, + "account-1"))) return 77; if (NULL == (twister_url = TALER_TESTING_prepare_twister - (CONFIG_FILE))) + (CONFIG_FILE))) { GNUNET_free (fakebank_url); return 77; diff --git a/src/bank-lib/test_bank_interpreter.c b/src/bank-lib/test_bank_interpreter.c index 9430e84bb..7f30f5050 100644 --- a/src/bank-lib/test_bank_interpreter.c +++ b/src/bank-lib/test_bank_interpreter.c @@ -118,7 +118,7 @@ find_command (const struct InterpreterState *is, "Attempt to lookup command for empty label\n"); return NULL; } - for (unsigned int i=0;TBI_OC_END != (cmd = &is->commands[i])->oc;i++) + for (unsigned int i = 0; TBI_OC_END != (cmd = &is->commands[i])->oc; i++) if ( (NULL != cmd->label) && (0 == strcmp (cmd->label, label)) ) @@ -144,7 +144,7 @@ test_cancelled (struct InterpreterState *is, { const struct TBI_Command *cmd = &is->commands[off]; - for (unsigned int i=0;iip;i++) + for (unsigned int i = 0; iip; i++) { const struct TBI_Command *c = &is->commands[i]; @@ -238,7 +238,7 @@ build_history (struct InterpreterState *is, ok = GNUNET_NO; if (NULL == ref) ok = GNUNET_YES; - for (unsigned int off = start;off != end + inc; off += inc) + for (unsigned int off = start; off != end + inc; off += inc) { const struct TBI_Command *pos = &is->commands[off]; int cancelled; @@ -262,10 +262,12 @@ build_history (struct InterpreterState *is, if ( (GNUNET_YES == cancelled) && (0 == (cmd->details.history.direction & TALER_BANK_DIRECTION_CANCEL)) ) continue; - if ( ( (0 != (cmd->details.history.direction & TALER_BANK_DIRECTION_CREDIT)) && + if ( ( (0 != (cmd->details.history.direction + & TALER_BANK_DIRECTION_CREDIT)) && (cmd->details.history.account_number == pos->details.admin_add_incoming.credit_account_no)) || - ( (0 != (cmd->details.history.direction & TALER_BANK_DIRECTION_DEBIT)) && + ( (0 != (cmd->details.history.direction + & TALER_BANK_DIRECTION_DEBIT)) && (cmd->details.history.account_number == pos->details.admin_add_incoming.debit_account_no)) ) total++; /* found matching record */ @@ -283,7 +285,7 @@ build_history (struct InterpreterState *is, ok = GNUNET_NO; if (NULL == ref) ok = GNUNET_YES; - for (unsigned int off = start;off != end + inc; off += inc) + for (unsigned int off = start; off != end + inc; off += inc) { const struct TBI_Command *pos = &is->commands[off]; int cancelled; @@ -302,10 +304,12 @@ build_history (struct InterpreterState *is, continue; /* skip until we find the marker */ if (total >= cmd->details.history.num_results * inc) break; /* hit limit specified by command */ - if ( ( (0 != (cmd->details.history.direction & TALER_BANK_DIRECTION_CREDIT)) && + if ( ( (0 != (cmd->details.history.direction + & TALER_BANK_DIRECTION_CREDIT)) && (cmd->details.history.account_number == pos->details.admin_add_incoming.credit_account_no)) && - ( (0 != (cmd->details.history.direction & TALER_BANK_DIRECTION_DEBIT)) && + ( (0 != (cmd->details.history.direction + & TALER_BANK_DIRECTION_DEBIT)) && (cmd->details.history.account_number == pos->details.admin_add_incoming.debit_account_no)) ) { @@ -319,7 +323,8 @@ build_history (struct InterpreterState *is, (0 == (cmd->details.history.direction & TALER_BANK_DIRECTION_CANCEL)) ) continue; - if ( (0 != (cmd->details.history.direction & TALER_BANK_DIRECTION_CREDIT)) && + if ( (0 != (cmd->details.history.direction + & TALER_BANK_DIRECTION_CREDIT)) && (cmd->details.history.account_number == pos->details.admin_add_incoming.credit_account_no)) { @@ -329,11 +334,12 @@ build_history (struct InterpreterState *is, GNUNET_asprintf (&h[total].details.account_url, "payto://x-taler-bank/%s/%llu", "localhost:8080", - (unsigned long long) pos->details.admin_add_incoming.debit_account_no); + (unsigned long + long) pos->details.admin_add_incoming.debit_account_no); } if ( (0 != (cmd->details.history.direction & TALER_BANK_DIRECTION_DEBIT)) && - (cmd->details.history.account_number == - pos->details.admin_add_incoming.debit_account_no)) + (cmd->details.history.account_number == + pos->details.admin_add_incoming.debit_account_no)) { h[total].direction = TALER_BANK_DIRECTION_DEBIT; if (GNUNET_YES == cancelled) @@ -341,18 +347,22 @@ build_history (struct InterpreterState *is, GNUNET_asprintf (&h[total].details.account_url, "payto://x-taler-bank/%s/%llu", "localhost:8080", - (unsigned long long) pos->details.admin_add_incoming.credit_account_no); + (unsigned long + long) pos->details.admin_add_incoming.credit_account_no); } - if ( ( (0 != (cmd->details.history.direction & TALER_BANK_DIRECTION_CREDIT)) && + if ( ( (0 != (cmd->details.history.direction + & TALER_BANK_DIRECTION_CREDIT)) && (cmd->details.history.account_number == pos->details.admin_add_incoming.credit_account_no)) || - ( (0 != (cmd->details.history.direction & TALER_BANK_DIRECTION_DEBIT)) && + ( (0 != (cmd->details.history.direction + & TALER_BANK_DIRECTION_DEBIT)) && (cmd->details.history.account_number == pos->details.admin_add_incoming.debit_account_no)) ) { GNUNET_assert (GNUNET_OK == - TALER_string_to_amount (pos->details.admin_add_incoming.amount, - &h[total].details.amount)); + TALER_string_to_amount ( + pos->details.admin_add_incoming.amount, + &h[total].details.amount)); /* h[total].execution_date; // unknown here */ h[total].row_id = pos->details.admin_add_incoming.row_id; @@ -386,7 +396,7 @@ print_expected (struct History *h, (unsigned long long) h_len); GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Expected history:\n"); - for (uint64_t i=0;ictx, "http://localhost:8080", &auth, - cmd->details.admin_add_incoming.exchange_base_url, + cmd->details.admin_add_incoming. + exchange_base_url, cmd->details.admin_add_incoming.subject, &amount, - cmd->details.admin_add_incoming.debit_account_no, - cmd->details.admin_add_incoming.credit_account_no, + cmd->details.admin_add_incoming. + debit_account_no, + cmd->details.admin_add_incoming. + credit_account_no, &add_incoming_cb, is); if (NULL == cmd->details.admin_add_incoming.aih) @@ -813,8 +826,9 @@ interpreter_run (void *cls) cmd->details.expect_transfer.cmd_ref); GNUNET_assert (NULL != ref); GNUNET_assert (GNUNET_OK == - TALER_string_to_amount (ref->details.admin_add_incoming.amount, - &amount)); + TALER_string_to_amount ( + ref->details.admin_add_incoming.amount, + &amount)); { char *subject; @@ -822,8 +836,10 @@ interpreter_run (void *cls) TALER_FAKEBANK_check (is->fakebank, &amount, ref->details.admin_add_incoming.debit_account_no, - ref->details.admin_add_incoming.credit_account_no, - ref->details.admin_add_incoming.exchange_base_url, + ref->details.admin_add_incoming. + credit_account_no, + ref->details.admin_add_incoming. + exchange_base_url, &subject)) { GNUNET_break (0); @@ -841,7 +857,7 @@ interpreter_run (void *cls) GNUNET_free (subject); } next (is); - return; + return; case TBI_OC_EXPECT_TRANSFERS_EMPTY: if (GNUNET_OK != TALER_FAKEBANK_check_empty (is->fakebank)) { @@ -928,7 +944,7 @@ do_shutdown (void *cls) is->timeout_task = NULL; } - for (unsigned int i=0;TBI_OC_END != (cmd = &is->commands[i])->oc;i++) + for (unsigned int i = 0; TBI_OC_END != (cmd = &is->commands[i])->oc; i++) { switch (cmd->oc) { @@ -942,7 +958,8 @@ do_shutdown (void *cls) "Command %u (%s) did not complete\n", i, cmd->label); - TALER_BANK_admin_add_incoming_cancel (cmd->details.admin_add_incoming.aih); + TALER_BANK_admin_add_incoming_cancel ( + cmd->details.admin_add_incoming.aih); cmd->details.admin_add_incoming.aih = NULL; } break; @@ -1025,7 +1042,7 @@ TBI_run_interpreter (int *resultp, is); is->timeout_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply - (GNUNET_TIME_UNIT_SECONDS, 150), + (GNUNET_TIME_UNIT_SECONDS, 150), &do_timeout, is); GNUNET_SCHEDULER_add_shutdown (&do_shutdown, is); } diff --git a/src/bank-lib/test_bank_interpreter.h b/src/bank-lib/test_bank_interpreter.h index ae323055d..1f78ec0bd 100644 --- a/src/bank-lib/test_bank_interpreter.h +++ b/src/bank-lib/test_bank_interpreter.h @@ -136,7 +136,8 @@ struct TBI_Command } admin_add_incoming; - struct { + struct + { /** * For which account do we query the history. @@ -186,7 +187,8 @@ struct TBI_Command * If @e opcode is #TBI_OC_EXPECT_TRANSFER, this * specifies which transfer we expected. */ - struct { + struct + { /** * Label of the command of an /admin/add/incoming @@ -199,7 +201,8 @@ struct TBI_Command /** * Execute /reject operation. */ - struct { + struct + { /** * Reference to the matching transfer that is now to be rejected. diff --git a/src/bank-lib/testing_api_cmd_history.c b/src/bank-lib/testing_api_cmd_history.c index 013bb647d..e69cd7c1a 100644 --- a/src/bank-lib/testing_api_cmd_history.c +++ b/src/bank-lib/testing_api_cmd_history.c @@ -80,7 +80,7 @@ struct HistoryState /** * Set to GNUNET_YES if the callback detects something - * unexpected. + * unexpected. */ int failed; @@ -184,7 +184,7 @@ test_cancelled (struct TALER_TESTING_Interpreter *is, current_cmd = &is->commands[off]; TALER_LOG_INFO ("Is `%s' rejected?\n", current_cmd->label); - for (unsigned int i=0;iip;i++) + for (unsigned int i = 0; iip; i++) { const struct TALER_TESTING_Command *c = &is->commands[i]; @@ -195,7 +195,7 @@ test_cancelled (struct TALER_TESTING_Interpreter *is, * reject command to mark them as rejected. So errors * about "reject traits" not found are NOT fatal here */ if (GNUNET_OK != TALER_TESTING_get_trait_rejected - (c, 0, &rejected_reference)) + (c, 0, &rejected_reference)) continue; TALER_LOG_INFO ("Command `%s' was rejected by `%s'.\n", @@ -220,7 +220,7 @@ static void free_history (struct History *h, uint64_t h_len) { - for (uint64_t off = 0;offstart_date.abs_value_us) + hs->start_date.abs_value_us) { const struct GNUNET_TIME_Absolute *timestamp; GNUNET_assert (GNUNET_OK == - TALER_TESTING_get_trait_absolute_time (pos, - 0, - ×tamp)); + TALER_TESTING_get_trait_absolute_time (pos, + 0, + ×tamp)); GNUNET_assert (GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us != hs->end_date.abs_value_us); @@ -345,18 +345,18 @@ build_history (struct TALER_TESTING_Interpreter *is, { TALER_LOG_INFO ("`%s': start row given via reference `%s'\n", - TALER_TESTING_interpreter_get_current_label (is), - hs->start_row_reference); + TALER_TESTING_interpreter_get_current_label (is), + hs->start_row_reference); add_incoming_cmd = TALER_TESTING_interpreter_lookup_command - (is, hs->start_row_reference); + (is, hs->start_row_reference); GNUNET_assert (NULL != add_incoming_cmd); GNUNET_assert (GNUNET_OK == TALER_TESTING_get_trait_uint64 - (add_incoming_cmd, 0, &row_id_start)); + (add_incoming_cmd, 0, &row_id_start)); } GNUNET_assert ((0 != hs->num_results) || /* "/history" */ - (GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us != /* "/history-range" */ - hs->start_date.abs_value_us)); + (GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us != /* "/history-range" */ + hs->start_date.abs_value_us)); if (0 == is->ip) { @@ -388,7 +388,7 @@ build_history (struct TALER_TESTING_Interpreter *is, /* This loop counts how many commands _later than "start"_ belong * to the history of the caller. This is stored in the @var total * variable. */ - for (unsigned int off = start;off != end + inc; off += inc) + for (unsigned int off = start; off != end + inc; off += inc) { const struct TALER_TESTING_Command *pos = &is->commands[off]; int cancelled; @@ -418,7 +418,7 @@ build_history (struct TALER_TESTING_Interpreter *is, /* Seek "/history-range" starting row, _if_ that's the case */ if ((GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us != - hs->start_date.abs_value_us) && (GNUNET_YES != ok)) + hs->start_date.abs_value_us) && (GNUNET_YES != ok)) { const struct GNUNET_TIME_Absolute *timestamp; @@ -427,8 +427,8 @@ build_history (struct TALER_TESTING_Interpreter *is, ×tamp); TALER_LOG_DEBUG ("Seeking first row, start vs timestamp: %llu vs %llu\n", - (long long unsigned int) hs->start_date.abs_value_us, - (long long unsigned int) timestamp->abs_value_us); + (long long unsigned int) hs->start_date.abs_value_us, + (long long unsigned int) timestamp->abs_value_us); if (hs->start_date.abs_value_us <= timestamp->abs_value_us) { @@ -510,7 +510,7 @@ build_history (struct TALER_TESTING_Interpreter *is, /** * This loop _only_ populates the array of history elements. */ - for (unsigned int off = start;off != end + inc; off += inc) + for (unsigned int off = start; off != end + inc; off += inc) { const struct TALER_TESTING_Command *pos = &is->commands[off]; int cancelled; @@ -520,7 +520,7 @@ build_history (struct TALER_TESTING_Interpreter *is, const uint64_t *debit_account_no; if (GNUNET_OK != TALER_TESTING_GET_TRAIT_ROW_ID - (pos, &row_id)) + (pos, &row_id)) continue; if (NULL != row_id_start) @@ -531,7 +531,7 @@ build_history (struct TALER_TESTING_Interpreter *is, /** * Warning: this zeroing is superfluous, as * total doesn't get incremented if 'start' - * was given and couldn't be found. + * was given and couldn't be found. */ total = 0; ok = GNUNET_YES; @@ -541,7 +541,7 @@ build_history (struct TALER_TESTING_Interpreter *is, /* Seek "/history-range" starting row, _if_ that's the case */ if ((GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us != - hs->start_date.abs_value_us) && (GNUNET_YES != ok)) + hs->start_date.abs_value_us) && (GNUNET_YES != ok)) { const struct GNUNET_TIME_Absolute *timestamp; @@ -550,8 +550,8 @@ build_history (struct TALER_TESTING_Interpreter *is, ×tamp); TALER_LOG_DEBUG ("Seeking first row, start vs timestamp (2): %llu vs %llu\n", - (long long unsigned int) hs->start_date.abs_value_us, - (long long unsigned int) timestamp->abs_value_us); + (long long unsigned int) hs->start_date.abs_value_us, + (long long unsigned int) timestamp->abs_value_us); if (hs->start_date.abs_value_us <= timestamp->abs_value_us) { @@ -611,15 +611,15 @@ build_history (struct TALER_TESTING_Interpreter *is, if ( (GNUNET_YES == cancelled) && (0 == (hs->direction & TALER_BANK_DIRECTION_CANCEL)) ) { - TALER_LOG_WARNING ("`%s' was cancelled\n", - TALER_TESTING_interpreter_get_current_label - (is)); - continue; + TALER_LOG_WARNING ("`%s' was cancelled\n", + TALER_TESTING_interpreter_get_current_label + (is)); + continue; } - bank_hostname = strchr (hs->bank_url, ':'); - GNUNET_assert (NULL != bank_hostname); - bank_hostname += 3; + bank_hostname = strchr (hs->bank_url, ':'); + GNUNET_assert (NULL != bank_hostname); + bank_hostname += 3; /* Next two blocks only put the 'direction' and 'banking' * information. */ @@ -634,16 +634,16 @@ build_history (struct TALER_TESTING_Interpreter *is, GNUNET_asprintf (&h[total].details.account_url, - ('/' == bank_hostname[strlen(bank_hostname) -1]) - ? "payto://x-taler-bank/%s%llu" - : "payto://x-taler-bank/%s/%llu", - bank_hostname, - (unsigned long long) *debit_account_no); + ('/' == bank_hostname[strlen (bank_hostname) - 1]) + ? "payto://x-taler-bank/%s%llu" + : "payto://x-taler-bank/%s/%llu", + bank_hostname, + (unsigned long long) *debit_account_no); } /* Asked for debit, and account got the debit. */ if ( (0 != (hs->direction & TALER_BANK_DIRECTION_DEBIT)) && - (hs->account_no == *debit_account_no)) + (hs->account_no == *debit_account_no)) { h[total].direction = TALER_BANK_DIRECTION_DEBIT; if (GNUNET_YES == cancelled) @@ -651,11 +651,11 @@ build_history (struct TALER_TESTING_Interpreter *is, GNUNET_asprintf (&h[total].details.account_url, - ('/' == bank_hostname[strlen(bank_hostname) -1]) - ? "payto://x-taler-bank/%s%llu" - : "payto://x-taler-bank/%s/%llu", - bank_hostname, - (unsigned long long) *credit_account_no); + ('/' == bank_hostname[strlen (bank_hostname) - 1]) + ? "payto://x-taler-bank/%s%llu" + : "payto://x-taler-bank/%s/%llu", + bank_hostname, + (unsigned long long) *credit_account_no); } /* This block _completes_ the information of the current item, @@ -678,7 +678,7 @@ build_history (struct TALER_TESTING_Interpreter *is, (pos, 0, &subject)); GNUNET_assert (GNUNET_OK == TALER_TESTING_get_trait_url - (pos, 0, &exchange_url)); + (pos, 0, &exchange_url)); h[total].details.amount = *amount; @@ -821,12 +821,12 @@ history_cb (void *cls, total = build_history (is, &h); GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Expected history of length %llu, got %llu;" - " HTTP status code: %u, failed: %d\n", - (unsigned long long) total, - (unsigned long long) hs->results_obtained, - http_status, - hs->failed); + "Expected history of length %llu, got %llu;" + " HTTP status code: %u, failed: %d\n", + (unsigned long long) total, + (unsigned long long) hs->results_obtained, + http_status, + hs->failed); print_expected (h, total, UINT_MAX); free_history (h, total); TALER_TESTING_interpreter_fail (is); @@ -835,14 +835,14 @@ history_cb (void *cls, TALER_TESTING_interpreter_next (is); return; } - + if (MHD_HTTP_OK != http_status) { hs->hh = NULL; GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Unwanted response code from /history[-range]: %u\n", - http_status); + "Unwanted response code from /history[-range]: %u\n", + http_status); TALER_TESTING_interpreter_fail (is); return; } @@ -898,7 +898,7 @@ history_run (void *cls, const struct TALER_TESTING_Command *history_cmd; history_cmd = TALER_TESTING_interpreter_lookup_command - (is, hs->start_row_reference); + (is, hs->start_row_reference); if (NULL == history_cmd) TALER_TESTING_FAIL (is); @@ -940,7 +940,7 @@ history_range_run (void *cls, const struct TALER_TESTING_Command *cmd, struct TALER_TESTING_Interpreter *is) { - + struct HistoryState *hs = cls; const struct GNUNET_TIME_Absolute *start_date; const struct GNUNET_TIME_Absolute *end_date; @@ -948,17 +948,17 @@ history_range_run (void *cls, if (NULL != hs->start_row_reference) { - + const struct TALER_TESTING_Command *history_cmd; history_cmd = TALER_TESTING_interpreter_lookup_command - (is, hs->start_row_reference); + (is, hs->start_row_reference); if (NULL == history_cmd) TALER_TESTING_FAIL (is); if (GNUNET_OK != TALER_TESTING_get_trait_absolute_time - (history_cmd, 0, &start_date)) + (history_cmd, 0, &start_date)) TALER_TESTING_FAIL (is); hs->start_date = *start_date; } @@ -976,13 +976,13 @@ history_range_run (void *cls, const struct TALER_TESTING_Command *history_cmd; history_cmd = TALER_TESTING_interpreter_lookup_command - (is, hs->end_row_reference); + (is, hs->end_row_reference); if (NULL == history_cmd) TALER_TESTING_FAIL (is); if (GNUNET_OK != TALER_TESTING_get_trait_absolute_time - (history_cmd, 0, &end_date)) + (history_cmd, 0, &end_date)) TALER_TESTING_FAIL (is); hs->end_date = *end_date; } @@ -1019,7 +1019,7 @@ history_range_run (void *cls, static void history_cleanup (void *cls, - const struct TALER_TESTING_Command *cmd) + const struct TALER_TESTING_Command *cmd) { struct HistoryState *hs = cls; @@ -1046,19 +1046,19 @@ history_cleanup * @param start_row_reference reference to a command that can * offer a row identifier, to be used as the starting row * to accept in the result. - * @param num_result how many rows we want in the result. + * @param num_result how many rows we want in the result. * * @return the command. */ struct TALER_TESTING_Command TALER_TESTING_cmd_bank_history (const char *label, - const char *bank_url, - uint64_t account_no, - enum TALER_BANK_Direction direction, - unsigned int ascending, - const char *start_row_reference, - long long num_results) + const char *bank_url, + uint64_t account_no, + enum TALER_BANK_Direction direction, + unsigned int ascending, + const char *start_row_reference, + long long num_results) { struct HistoryState *hs; @@ -1105,12 +1105,12 @@ TALER_TESTING_cmd_bank_history struct TALER_TESTING_Command TALER_TESTING_cmd_bank_history_range (const char *label, - const char *bank_url, - uint64_t account_no, - enum TALER_BANK_Direction direction, - unsigned int ascending, - const char *start_row_reference, - const char *end_row_reference) + const char *bank_url, + uint64_t account_no, + enum TALER_BANK_Direction direction, + unsigned int ascending, + const char *start_row_reference, + const char *end_row_reference) { struct HistoryState *hs; @@ -1155,12 +1155,12 @@ TALER_TESTING_cmd_bank_history_range struct TALER_TESTING_Command TALER_TESTING_cmd_bank_history_range_with_dates (const char *label, - const char *bank_url, - uint64_t account_no, - enum TALER_BANK_Direction direction, - unsigned int ascending, - struct GNUNET_TIME_Absolute start_date, - struct GNUNET_TIME_Absolute end_date) + const char *bank_url, + uint64_t account_no, + enum TALER_BANK_Direction direction, + unsigned int ascending, + struct GNUNET_TIME_Absolute start_date, + struct GNUNET_TIME_Absolute end_date) { struct HistoryState *hs; diff --git a/src/bank-lib/testing_api_cmd_reject.c b/src/bank-lib/testing_api_cmd_reject.c index 46d67ff21..1f19a379d 100644 --- a/src/bank-lib/testing_api_cmd_reject.c +++ b/src/bank-lib/testing_api_cmd_reject.c @@ -97,7 +97,7 @@ reject_cb (void *cls, static void reject_cleanup (void *cls, - const struct TALER_TESTING_Command *cmd) + const struct TALER_TESTING_Command *cmd) { struct RejectState *rs = cls; @@ -119,8 +119,8 @@ reject_cleanup */ static void reject_run (void *cls, - const struct TALER_TESTING_Command *cmd, - struct TALER_TESTING_Interpreter *is) + const struct TALER_TESTING_Command *cmd, + struct TALER_TESTING_Interpreter *is) { struct RejectState *rs = cls; const struct TALER_TESTING_Command *deposit_cmd; @@ -129,7 +129,7 @@ reject_run (void *cls, extern struct TALER_BANK_AuthenticationData AUTHS[]; deposit_cmd = TALER_TESTING_interpreter_lookup_command - (is, rs->deposit_reference); + (is, rs->deposit_reference); if (NULL == deposit_cmd) TALER_TESTING_FAIL (is); @@ -145,7 +145,7 @@ reject_run (void *cls, (unsigned long long) *credit_account); rs->rh = TALER_BANK_reject (is->ctx, rs->bank_url, - &AUTHS[*credit_account -1], + &AUTHS[*credit_account - 1], *credit_account, *row_id, &reject_cb, diff --git a/src/bank-lib/testing_api_helpers.c b/src/bank-lib/testing_api_helpers.c index f61f66649..db813df2a 100644 --- a/src/bank-lib/testing_api_helpers.c +++ b/src/bank-lib/testing_api_helpers.c @@ -44,7 +44,7 @@ struct TALER_BANK_AuthenticationData AUTHS[] = { /* User credentials */ {.method = TALER_BANK_AUTH_BASIC, .details.basic.username = USER_USERNAME, - .details.basic.password = USER_PASSWORD } + .details.basic.password = USER_PASSWORD } }; /** @@ -115,14 +115,14 @@ TALER_TESTING_run_bank (const char *config_filename, serve_arg = "serve-uwsgi"; bank_proc = GNUNET_OS_start_process - (GNUNET_NO, - GNUNET_OS_INHERIT_STD_ALL, - NULL, NULL, NULL, - "taler-bank-manage", - "taler-bank-manage", - "-c", config_filename, - "--with-db", database, - serve_arg, NULL); + (GNUNET_NO, + GNUNET_OS_INHERIT_STD_ALL, + NULL, NULL, NULL, + "taler-bank-manage", + "taler-bank-manage", + "-c", config_filename, + "--with-db", database, + serve_arg, NULL); if (NULL == bank_proc) BANK_FAIL (); @@ -136,22 +136,22 @@ TALER_TESTING_run_bank (const char *config_filename, "Waiting for `taler-bank-manage' to be ready"); iter = 0; do + { + if (10 == iter) { - if (10 == iter) - { - fprintf ( - stderr, - "Failed to launch `taler-bank-manage' (or `wget')\n"); - GNUNET_OS_process_kill (bank_proc, - SIGTERM); - GNUNET_OS_process_wait (bank_proc); - GNUNET_OS_process_destroy (bank_proc); - BANK_FAIL (); - } - fprintf (stderr, "."); - sleep (1); - iter++; + fprintf ( + stderr, + "Failed to launch `taler-bank-manage' (or `wget')\n"); + GNUNET_OS_process_kill (bank_proc, + SIGTERM); + GNUNET_OS_process_wait (bank_proc); + GNUNET_OS_process_destroy (bank_proc); + BANK_FAIL (); } + fprintf (stderr, "."); + sleep (1); + iter++; + } while (0 != system (wget_cmd)); fprintf (stderr, "\n"); @@ -183,11 +183,11 @@ TALER_TESTING_prepare_bank (const char *config_filename) cfg = GNUNET_CONFIGURATION_create (); if (GNUNET_OK != GNUNET_CONFIGURATION_load - (cfg, config_filename)) + (cfg, config_filename)) BANK_FAIL (); if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string - (cfg, "bank", "DATABASE", &database)) + (cfg, "bank", "DATABASE", &database)) { GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, "bank", @@ -197,7 +197,7 @@ TALER_TESTING_prepare_bank (const char *config_filename) } if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number - (cfg, "bank", "HTTP_PORT", &port)) + (cfg, "bank", "HTTP_PORT", &port)) { GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, "bank", @@ -208,27 +208,27 @@ TALER_TESTING_prepare_bank (const char *config_filename) GNUNET_CONFIGURATION_destroy (cfg); if (GNUNET_OK != GNUNET_NETWORK_test_port_free - (IPPROTO_TCP, (uint16_t) port)) + (IPPROTO_TCP, (uint16_t) port)) { fprintf (stderr, "Required port %llu not available, skipping.\n", - port); + port); BANK_FAIL (); } /* DB preparation */ if (NULL == - (dbreset_proc = GNUNET_OS_start_process ( - GNUNET_NO, - GNUNET_OS_INHERIT_STD_ALL, - NULL, NULL, NULL, - "taler-bank-manage", - "taler-bank-manage", - "-c", "bank.conf", - "--with-db", database, - "django", - "flush", - "--no-input", NULL))) + (dbreset_proc = GNUNET_OS_start_process ( + GNUNET_NO, + GNUNET_OS_INHERIT_STD_ALL, + NULL, NULL, NULL, + "taler-bank-manage", + "taler-bank-manage", + "-c", "bank.conf", + "--with-db", database, + "django", + "flush", + "--no-input", NULL))) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to flush the bank db.\n"); diff --git a/src/benchmark/taler-exchange-benchmark.c b/src/benchmark/taler-exchange-benchmark.c index 094f23c74..d106eb557 100644 --- a/src/benchmark/taler-exchange-benchmark.c +++ b/src/benchmark/taler-exchange-benchmark.c @@ -41,7 +41,8 @@ #include "taler_error_codes.h" /* Error codes. */ -enum BenchmarkError { +enum BenchmarkError +{ MISSING_BANK_URL, FAILED_TO_LAUNCH_BANK, BAD_CLI_ARG, @@ -67,20 +68,23 @@ enum BenchmarkError { #define FIRST_INSTRUCTION -1 #define CMD_TRANSFER_TO_EXCHANGE(label, amount) \ - TALER_TESTING_cmd_fakebank_transfer_retry \ + TALER_TESTING_cmd_fakebank_transfer_retry \ (TALER_TESTING_cmd_fakebank_transfer (label, amount, \ - exchange_bank_account.details.x_taler_bank.bank_base_url, \ - USER_ACCOUNT_NUMBER, \ - exchange_bank_account.details.x_taler_bank.no, \ - "dummy_user", \ - "dummy_password", \ - "http://example.com/")) + exchange_bank_account.details. \ + x_taler_bank.bank_base_url, \ + USER_ACCOUNT_NUMBER, \ + exchange_bank_account.details. \ + x_taler_bank.no, \ + "dummy_user", \ + "dummy_password", \ + "http://example.com/")) /** * What mode should the benchmark run in? */ -enum BenchmarkMode { +enum BenchmarkMode +{ /** * Run as client (with fakebank), also starts a remote exchange. */ @@ -222,7 +226,7 @@ eval_probability (float probability) float random_01; random = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, - UINT64_MAX); + UINT64_MAX); random_01 = (double) random / UINT64_MAX; return (random_01 <= probability) ? GNUNET_OK : GNUNET_NO; } @@ -239,9 +243,9 @@ run (void *cls, struct TALER_Amount withdraw_fee; char *withdraw_fee_str; struct TALER_TESTING_Command all_commands - [howmany_reserves * (1 + /* Withdraw block */ - howmany_coins) + /* All units */ - 1 /* End CMD */]; + [howmany_reserves * (1 /* Withdraw block */ + + howmany_coins) /* All units */ + + 1 /* End CMD */]; char *AMOUNT_5; char *AMOUNT_4; char *AMOUNT_1; @@ -250,7 +254,8 @@ run (void *cls, GNUNET_asprintf (&AMOUNT_4, "%s:4", currency); GNUNET_asprintf (&AMOUNT_1, "%s:1", currency); - GNUNET_assert (GNUNET_OK == TALER_amount_get_zero (currency, &total_reserve_amount)); + GNUNET_assert (GNUNET_OK == TALER_amount_get_zero (currency, + &total_reserve_amount)); total_reserve_amount.value = 5 * howmany_coins; GNUNET_asprintf (&withdraw_fee_str, @@ -274,8 +279,8 @@ run (void *cls, { struct TALER_TESTING_Command make_reserve[] = { CMD_TRANSFER_TO_EXCHANGE - (create_reserve_label, - TALER_amount_to_string (&total_reserve_amount)), + (create_reserve_label, + TALER_amount_to_string (&total_reserve_amount)), TALER_TESTING_cmd_end () }; char *batch_label; @@ -303,24 +308,24 @@ run (void *cls, i + (howmany_coins * j)); unit[0] = TALER_TESTING_cmd_withdraw_with_retry - (TALER_TESTING_cmd_withdraw_amount - (withdraw_label, - create_reserve_label, - AMOUNT_5, - MHD_HTTP_OK)); + (TALER_TESTING_cmd_withdraw_amount + (withdraw_label, + create_reserve_label, + AMOUNT_5, + MHD_HTTP_OK)); unit[1] = TALER_TESTING_cmd_deposit_with_retry - (TALER_TESTING_cmd_deposit - ("deposit", - withdraw_label, - 0, /* Index of the one withdrawn coin in the traits. */ - TALER_TESTING_make_wire_details - (USER_ACCOUNT_NUMBER, - exchange_bank_account.details.x_taler_bank.hostname), - order_enc, - GNUNET_TIME_UNIT_ZERO, - AMOUNT_1, - MHD_HTTP_OK)); + (TALER_TESTING_cmd_deposit + ("deposit", + withdraw_label, + 0, /* Index of the one withdrawn coin in the traits. */ + TALER_TESTING_make_wire_details + (USER_ACCOUNT_NUMBER, + exchange_bank_account.details.x_taler_bank.hostname), + order_enc, + GNUNET_TIME_UNIT_ZERO, + AMOUNT_1, + MHD_HTTP_OK)); if (eval_probability (refresh_rate / 100.0)) { @@ -337,23 +342,23 @@ run (void *cls, j); unit[2] = TALER_TESTING_cmd_refresh_melt_with_retry - (TALER_TESTING_cmd_refresh_melt - (melt_label, - withdraw_label, - MHD_HTTP_OK, - NULL)); + (TALER_TESTING_cmd_refresh_melt + (melt_label, + withdraw_label, + MHD_HTTP_OK, + NULL)); unit[3] = TALER_TESTING_cmd_refresh_reveal_with_retry - (TALER_TESTING_cmd_refresh_reveal - (reveal_label, - melt_label, - MHD_HTTP_OK)); + (TALER_TESTING_cmd_refresh_reveal + (reveal_label, + melt_label, + MHD_HTTP_OK)); unit[4] = TALER_TESTING_cmd_refresh_link_with_retry - (TALER_TESTING_cmd_refresh_link - ("refresh-link", - reveal_label, - MHD_HTTP_OK)); + (TALER_TESTING_cmd_refresh_link + ("refresh-link", + reveal_label, + MHD_HTTP_OK)); unit[5] = TALER_TESTING_cmd_end (); } else @@ -402,7 +407,7 @@ launch_fakebank (void *cls) const char *bank_base_url = cls; const char *port; long pnum; - struct TALER_FAKEBANK_Handle * fakebank; + struct TALER_FAKEBANK_Handle *fakebank; port = strrchr (bank_base_url, (unsigned char) ':'); @@ -460,7 +465,8 @@ parallel_benchmark (TALER_TESTING_Main main_cb, NULL == loglev ? "INFO" : loglev, logfile); GNUNET_SCHEDULER_run (&launch_fakebank, - exchange_bank_account.details.x_taler_bank.bank_base_url); + exchange_bank_account.details.x_taler_bank. + bank_base_url); exit (0); } if (-1 == fakebank) @@ -534,9 +540,9 @@ parallel_benchmark (TALER_TESTING_Main main_cb, remote_cmd); GNUNET_assert (NULL != (exchange_slave_pipe = - GNUNET_DISK_pipe (GNUNET_YES, - GNUNET_YES, - 0, 0))); + GNUNET_DISK_pipe (GNUNET_YES, + GNUNET_YES, + 0, 0))); exchange_slave = GNUNET_OS_start_process (GNUNET_NO, GNUNET_OS_INHERIT_STD_OUT_AND_ERR, @@ -586,7 +592,7 @@ parallel_benchmark (TALER_TESTING_Main main_cb, start_time = GNUNET_TIME_absolute_get (); result = GNUNET_OK; - for (unsigned int i=0;iuser_config_file); + cfg_filename = GNUNET_strdup ( + GNUNET_OS_project_data_get ()->user_config_file); cfg = GNUNET_CONFIGURATION_create (); if (GNUNET_OK != GNUNET_CONFIGURATION_load (cfg, @@ -822,21 +830,22 @@ main (int argc, GNUNET_CONFIGURATION_iterate_sections (cfg, - &pick_exchange_account_cb, - &bank_details_section); + &pick_exchange_account_cb, + &bank_details_section); if (NULL == bank_details_section) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - _("Missing specification of bank account in configuration\n")); + _ ( + "Missing specification of bank account in configuration\n")); return BAD_CONFIG_FILE; } if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string - (cfg, - bank_details_section, - "url", - &exchange_payto_url)) + (cfg, + bank_details_section, + "url", + &exchange_payto_url)) { GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, bank_details_section, @@ -846,10 +855,10 @@ main (int argc, if (TALER_EC_NONE != TALER_WIRE_payto_to_account (exchange_payto_url, - &exchange_bank_account)) + &exchange_bank_account)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - _("Malformed payto:// URL `%s' in configuration\n"), + _ ("Malformed payto:// URL `%s' in configuration\n"), exchange_payto_url); GNUNET_free (exchange_payto_url); return BAD_CONFIG_FILE; @@ -857,7 +866,8 @@ main (int argc, if (TALER_PAC_X_TALER_BANK != exchange_bank_account.type) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - _("Malformed payto:// URL `%s' in configuration: x-taler-bank required\n"), + _ ( + "Malformed payto:// URL `%s' in configuration: x-taler-bank required\n"), exchange_payto_url); GNUNET_free (exchange_payto_url); return BAD_CONFIG_FILE; @@ -869,13 +879,13 @@ main (int argc, struct GNUNET_OS_Process *compute_wire_response; compute_wire_response = GNUNET_OS_start_process - (GNUNET_NO, - GNUNET_OS_INHERIT_STD_ALL, - NULL, NULL, NULL, - "taler-exchange-wire", - "taler-exchange-wire", - "-c", cfg_filename, - NULL); + (GNUNET_NO, + GNUNET_OS_INHERIT_STD_ALL, + NULL, NULL, NULL, + "taler-exchange-wire", + "taler-exchange-wire", + "-c", cfg_filename, + NULL); if (NULL == compute_wire_response) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, @@ -889,8 +899,8 @@ main (int argc, GNUNET_assert (GNUNET_OK == TALER_TESTING_prepare_exchange (cfg_filename, - &auditor_url, - &exchange_url)); + &auditor_url, + &exchange_url)); } else { @@ -952,7 +962,7 @@ main (int argc, if (GNUNET_OK == result) { struct rusage usage; - GNUNET_assert (0 == getrusage(RUSAGE_CHILDREN, &usage)); + GNUNET_assert (0 == getrusage (RUSAGE_CHILDREN, &usage)); fprintf (stdout, "Executed (Withdraw=%u, Deposit=%u, Refresh~=%5.2f) * Reserve=%u * Parallel=%u, operations in %s\n", howmany_coins, @@ -961,16 +971,16 @@ main (int argc, howmany_reserves, howmany_clients, GNUNET_STRINGS_relative_time_to_string - (duration, - GNUNET_NO)); + (duration, + GNUNET_NO)); fprintf (stdout, "(approximately %s/coin)\n", GNUNET_STRINGS_relative_time_to_string - (GNUNET_TIME_relative_divide (duration, - (unsigned long long) howmany_coins * - howmany_reserves * - howmany_clients), - GNUNET_YES)); + (GNUNET_TIME_relative_divide (duration, + (unsigned long long) howmany_coins + * howmany_reserves + * howmany_clients), + GNUNET_YES)); fprintf (stdout, "RAW: %04u %04u %04u %16llu\n", howmany_coins, @@ -978,8 +988,10 @@ main (int argc, howmany_clients, (unsigned long long) duration.rel_value_us); fprintf (stdout, "cpu time: sys %llu user %llu\n", \ - (unsigned long long) (usage.ru_stime.tv_sec * 1000 * 1000 + usage.ru_stime.tv_usec), - (unsigned long long) (usage.ru_utime.tv_sec * 1000 * 1000 + usage.ru_utime.tv_usec)); + (unsigned long long) (usage.ru_stime.tv_sec * 1000 * 1000 + + usage.ru_stime.tv_usec), + (unsigned long long) (usage.ru_utime.tv_sec * 1000 * 1000 + + usage.ru_utime.tv_usec)); } return (GNUNET_OK == result) ? 0 : result; } diff --git a/src/exchange-tools/taler-exchange-dbinit.c b/src/exchange-tools/taler-exchange-dbinit.c index 77aef1ee5..afc1b837e 100644 --- a/src/exchange-tools/taler-exchange-dbinit.c +++ b/src/exchange-tools/taler-exchange-dbinit.c @@ -74,11 +74,11 @@ run (void *cls, return; } if (gc_db) - { - if (GNUNET_SYSERR == plugin->gc (plugin->cls)) - fprintf (stderr, - "Garbage collection failed!\n"); - } + { + if (GNUNET_SYSERR == plugin->gc (plugin->cls)) + fprintf (stderr, + "Garbage collection failed!\n"); + } TALER_EXCHANGEDB_plugin_unload (plugin); } @@ -97,13 +97,13 @@ main (int argc, { const struct GNUNET_GETOPT_CommandLineOption options[] = { GNUNET_GETOPT_option_flag ('r', - "reset", - "reset database (DANGEROUS: all existing data is lost!)", - &reset_db), + "reset", + "reset database (DANGEROUS: all existing data is lost!)", + &reset_db), GNUNET_GETOPT_option_flag ('g', - "gc", - "garbage collect database", - &gc_db), + "gc", + "garbage collect database", + &gc_db), GNUNET_GETOPT_OPTION_END }; @@ -118,9 +118,9 @@ main (int argc, if (GNUNET_OK != GNUNET_PROGRAM_run (argc, argv, "taler-exchange-dbinit", - "Initialize Taler exchange database", - options, - &run, NULL)) + "Initialize Taler exchange database", + options, + &run, NULL)) return 1; return global_ret; } diff --git a/src/exchange-tools/taler-exchange-keycheck.c b/src/exchange-tools/taler-exchange-keycheck.c index c657454af..ac452a058 100644 --- a/src/exchange-tools/taler-exchange-keycheck.c +++ b/src/exchange-tools/taler-exchange-keycheck.c @@ -61,7 +61,7 @@ signkeys_iter (void *cls, "Iterating over key `%s' for start time %s\n", filename, GNUNET_STRINGS_absolute_time_to_string - (GNUNET_TIME_absolute_ntoh (ski->issue.start))); + (GNUNET_TIME_absolute_ntoh (ski->issue.start))); if (ntohl (ski->issue.purpose.size) != (sizeof (struct TALER_ExchangeSigningKeyValidityPS))) @@ -71,9 +71,12 @@ signkeys_iter (void *cls, filename); return GNUNET_SYSERR; } - if ( (0 != GNUNET_TIME_absolute_ntoh (ski->issue.start).abs_value_us % 1000000) || - (0 != GNUNET_TIME_absolute_ntoh (ski->issue.expire).abs_value_us % 1000000) || - (0 != GNUNET_TIME_absolute_ntoh (ski->issue.end).abs_value_us % 1000000) ) + if ( (0 != GNUNET_TIME_absolute_ntoh (ski->issue.start).abs_value_us + % 1000000) || + (0 != GNUNET_TIME_absolute_ntoh (ski->issue.expire).abs_value_us + % 1000000) || + (0 != GNUNET_TIME_absolute_ntoh (ski->issue.end).abs_value_us + % 1000000) ) { fprintf (stderr, "Timestamps are not multiples of a round second\n"); @@ -127,7 +130,8 @@ exchange_signkeys_check () static int denomkeys_iter (void *cls, const char *alias, - const struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *dki) + const struct + TALER_EXCHANGEDB_DenominationKeyIssueInformation *dki) { struct GNUNET_HashCode hc; @@ -140,10 +144,14 @@ denomkeys_iter (void *cls, return GNUNET_SYSERR; } - if ( (0 != GNUNET_TIME_absolute_ntoh (dki->issue.properties.start).abs_value_us % 1000000) || - (0 != GNUNET_TIME_absolute_ntoh (dki->issue.properties.expire_withdraw).abs_value_us % 1000000) || - (0 != GNUNET_TIME_absolute_ntoh (dki->issue.properties.expire_legal).abs_value_us % 1000000) || - (0 != GNUNET_TIME_absolute_ntoh (dki->issue.properties.expire_deposit).abs_value_us % 1000000) ) + if ( (0 != GNUNET_TIME_absolute_ntoh ( + dki->issue.properties.start).abs_value_us % 1000000) || + (0 != GNUNET_TIME_absolute_ntoh ( + dki->issue.properties.expire_withdraw).abs_value_us % 1000000) || + (0 != GNUNET_TIME_absolute_ntoh ( + dki->issue.properties.expire_legal).abs_value_us % 1000000) || + (0 != GNUNET_TIME_absolute_ntoh ( + dki->issue.properties.expire_deposit).abs_value_us % 1000000) ) { fprintf (stderr, "Timestamps are not multiples of a round second\n"); @@ -151,10 +159,11 @@ denomkeys_iter (void *cls, } if (GNUNET_OK != - GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_MASTER_DENOMINATION_KEY_VALIDITY, - &dki->issue.properties.purpose, - &dki->issue.signature.eddsa_signature, - &dki->issue.properties.master.eddsa_pub)) + GNUNET_CRYPTO_eddsa_verify ( + TALER_SIGNATURE_MASTER_DENOMINATION_KEY_VALIDITY, + &dki->issue.properties.purpose, + &dki->issue.signature.eddsa_signature, + &dki->issue.properties.master.eddsa_pub)) { fprintf (stderr, "Denomination key for `%s' has invalid signature\n", @@ -194,7 +203,8 @@ exchange_denomkeys_check () "exchange", "master_public_key", &master_public_key_from_cfg, - sizeof (struct GNUNET_CRYPTO_EddsaPublicKey))) + sizeof (struct + GNUNET_CRYPTO_EddsaPublicKey))) { GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, "exchange", @@ -268,9 +278,9 @@ main (int argc, char *const *argv) if (GNUNET_OK != GNUNET_PROGRAM_run (argc, argv, "taler-exchange-keycheck", - "Check keys of the exchange for validity", - options, - &run, NULL)) + "Check keys of the exchange for validity", + options, + &run, NULL)) return 1; return global_ret; diff --git a/src/exchange-tools/taler-exchange-keyup.c b/src/exchange-tools/taler-exchange-keyup.c index 4c8682e54..8486f02cf 100644 --- a/src/exchange-tools/taler-exchange-keyup.c +++ b/src/exchange-tools/taler-exchange-keyup.c @@ -297,7 +297,8 @@ get_cointype_dir (const struct CoinTypeParams *p) hash_coin_type (p, &hash); hash_str = GNUNET_STRINGS_data_to_string_alloc (&hash, - sizeof (struct GNUNET_HashCode)); + sizeof (struct + GNUNET_HashCode)); GNUNET_assert (NULL != hash_str); GNUNET_assert (HASH_CUTOFF <= strlen (hash_str) + 1); hash_str[HASH_CUTOFF] = 0; @@ -311,7 +312,8 @@ get_cointype_dir (const struct CoinTypeParams *p) GNUNET_snprintf (dir, sizeof (dir), - "%s" DIR_SEPARATOR_STR TALER_EXCHANGEDB_DIR_DENOMINATION_KEYS DIR_SEPARATOR_STR "%s-%s", + "%s" DIR_SEPARATOR_STR TALER_EXCHANGEDB_DIR_DENOMINATION_KEYS + DIR_SEPARATOR_STR "%s-%s", exchange_directory, val_str, hash_str); @@ -462,7 +464,8 @@ static void create_signkey_issue_priv (struct GNUNET_TIME_Absolute start, struct GNUNET_TIME_Relative duration, struct GNUNET_TIME_Absolute end, - struct TALER_EXCHANGEDB_PrivateSigningKeyInformationP *pi) + struct TALER_EXCHANGEDB_PrivateSigningKeyInformationP + *pi) { struct GNUNET_CRYPTO_EddsaPrivateKey *priv; struct TALER_ExchangeSigningKeyValidityPS *issue = &pi->issue; @@ -478,7 +481,8 @@ create_signkey_issue_priv (struct GNUNET_TIME_Absolute start, GNUNET_CRYPTO_eddsa_key_get_public (&pi->signkey_priv.eddsa_priv, &issue->signkey_pub.eddsa_pub); issue->purpose.purpose = htonl (TALER_SIGNATURE_MASTER_SIGNING_KEY_VALIDITY); - issue->purpose.size = htonl (sizeof (struct TALER_ExchangeSigningKeyValidityPS)); + issue->purpose.size = htonl (sizeof (struct + TALER_ExchangeSigningKeyValidityPS)); GNUNET_assert (GNUNET_OK == GNUNET_CRYPTO_eddsa_sign (&master_priv.eddsa_priv, &issue->purpose, @@ -753,20 +757,23 @@ get_cointype_params (const char *ct, */ static void create_denomkey_issue (const struct CoinTypeParams *params, - struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *dki) + struct TALER_EXCHANGEDB_DenominationKeyIssueInformation * + dki) { dki->denom_priv.rsa_private_key = GNUNET_CRYPTO_rsa_private_key_create (params->rsa_keysize); GNUNET_assert (NULL != dki->denom_priv.rsa_private_key); dki->denom_pub.rsa_public_key - = GNUNET_CRYPTO_rsa_private_key_get_public (dki->denom_priv.rsa_private_key); + = GNUNET_CRYPTO_rsa_private_key_get_public ( + dki->denom_priv.rsa_private_key); GNUNET_CRYPTO_rsa_public_key_hash (dki->denom_pub.rsa_public_key, &dki->issue.properties.denom_hash); dki->issue.properties.master = master_public_key; dki->issue.properties.start = GNUNET_TIME_absolute_hton (params->anchor); dki->issue.properties.expire_withdraw = - GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_add (params->anchor, - params->duration_withdraw)); + GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_add (params->anchor, + params-> + duration_withdraw)); dki->issue.properties.expire_deposit = GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_add (params->anchor, params->duration_spend)); @@ -803,7 +810,7 @@ create_denomkey_issue (const struct CoinTypeParams *params, */ static void exchange_keys_update_cointype (void *cls, - const char *coin_alias) + const char *coin_alias) { int *ret = cls; struct CoinTypeParams p; @@ -837,7 +844,7 @@ exchange_keys_update_cointype (void *cls, GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_difference (p.anchor, lookahead_sign_stamp), - GNUNET_NO)); + GNUNET_NO)); dkf = get_cointype_file (&p, p.anchor); GNUNET_break (GNUNET_YES != @@ -853,14 +860,16 @@ exchange_keys_update_cointype (void *cls, &denomkey_issue); if (GNUNET_OK != TALER_EXCHANGEDB_denomination_key_write (dkf, - &denomkey_issue)) + &denomkey_issue)) { fprintf (stderr, "Failed to write denomination key information to file `%s'.\n", dkf); *ret = GNUNET_SYSERR; - GNUNET_CRYPTO_rsa_private_key_free (denomkey_issue.denom_priv.rsa_private_key); - GNUNET_CRYPTO_rsa_public_key_free (denomkey_issue.denom_pub.rsa_public_key); + GNUNET_CRYPTO_rsa_private_key_free ( + denomkey_issue.denom_priv.rsa_private_key); + GNUNET_CRYPTO_rsa_public_key_free ( + denomkey_issue.denom_pub.rsa_public_key); return; } if ( (NULL != auditor_output_file) && @@ -875,11 +884,14 @@ exchange_keys_update_cointype (void *cls, auditorrequestfile, STRERROR (errno)); *ret = GNUNET_SYSERR; - GNUNET_CRYPTO_rsa_private_key_free (denomkey_issue.denom_priv.rsa_private_key); - GNUNET_CRYPTO_rsa_public_key_free (denomkey_issue.denom_pub.rsa_public_key); + GNUNET_CRYPTO_rsa_private_key_free ( + denomkey_issue.denom_priv.rsa_private_key); + GNUNET_CRYPTO_rsa_public_key_free ( + denomkey_issue.denom_pub.rsa_public_key); return; } - GNUNET_CRYPTO_rsa_private_key_free (denomkey_issue.denom_priv.rsa_private_key); + GNUNET_CRYPTO_rsa_private_key_free ( + denomkey_issue.denom_priv.rsa_private_key); GNUNET_CRYPTO_rsa_public_key_free (denomkey_issue.denom_pub.rsa_public_key); p.anchor = GNUNET_TIME_absolute_add (p.anchor, p.duration_withdraw); @@ -1146,7 +1158,7 @@ static int revoke_denomination (const struct GNUNET_HashCode *hc) { char *basedir; - + if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (kcfg, "exchange", @@ -1193,7 +1205,7 @@ run (void *cls, if (now.abs_value_us != now_tmp.abs_value_us) { - /* The user gave "--now", use it */ + /* The user gave "--now", use it */ now = now_tmp; } /* The user _might_ have given "--now" but it matched @@ -1331,7 +1343,8 @@ run (void *cls, "exchange", "master_public_key", &master_public_key_from_cfg, - sizeof (struct GNUNET_CRYPTO_EddsaPublicKey))) + sizeof (struct + GNUNET_CRYPTO_EddsaPublicKey))) { GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, "exchange", @@ -1346,7 +1359,7 @@ run (void *cls, GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR, "exchange", "master_public_key", - _("does not match with private key")); + _ ("does not match with private key")); global_ret = 1; return; } @@ -1369,7 +1382,7 @@ run (void *cls, GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR, "exchange", "lookahead_sign", - _("must not be zero")); + _ ("must not be zero")); global_ret = 1; return; } @@ -1457,10 +1470,10 @@ main (int argc, now = now_tmp = GNUNET_TIME_absolute_get (); if (GNUNET_OK != GNUNET_PROGRAM_run (argc, argv, - "taler-exchange-keyup", - "Setup signing and denomination keys for a Taler exchange", - options, - &run, NULL)) + "taler-exchange-keyup", + "Setup signing and denomination keys for a Taler exchange", + options, + &run, NULL)) return 1; if (NULL != auditor_output_file) { diff --git a/src/exchange-tools/taler-exchange-wire.c b/src/exchange-tools/taler-exchange-wire.c index 366b69ecd..1a057e4e1 100644 --- a/src/exchange-tools/taler-exchange-wire.c +++ b/src/exchange-tools/taler-exchange-wire.c @@ -60,7 +60,7 @@ sign_account_data (void *cls, char *json_out; FILE *out; int ret; - + if (GNUNET_NO == ai->credit_enabled) return; if (NULL == ai->wire_response_filename) @@ -71,12 +71,12 @@ sign_account_data (void *cls, global_ret = 1; return; } - + wire = TALER_JSON_exchange_wire_signature_make (ai->payto_url, &master_priv); GNUNET_assert (NULL != wire); json_out = json_dumps (wire, - JSON_INDENT(2)); + JSON_INDENT (2)); json_decref (wire); GNUNET_assert (NULL != json_out); if (GNUNET_OK != @@ -242,10 +242,10 @@ main (int argc, NULL)); if (GNUNET_OK != GNUNET_PROGRAM_run (argc, argv, - "taler-exchange-wire", - "Setup /wire response", - options, - &run, NULL)) + "taler-exchange-wire", + "Setup /wire response", + options, + &run, NULL)) return 1; return global_ret; } diff --git a/src/exchange-tools/taler-wire.c b/src/exchange-tools/taler-wire.c index f27caf749..213c1eff3 100644 --- a/src/exchange-tools/taler-wire.c +++ b/src/exchange-tools/taler-wire.c @@ -151,7 +151,7 @@ confirmation_cb (void *cls, GNUNET_assert (NULL != emsg); fprintf (stderr, "%s", - emsg); + emsg); GNUNET_SCHEDULER_shutdown (); return; } @@ -179,22 +179,22 @@ prepare_cb (void *cls, struct TALER_WIRE_ExecuteHandle *eh; if (NULL == (eh = plugin_handle->execute_wire_transfer - (plugin_handle->cls, - buf, - buf_size, - confirmation_cb, - NULL))) + (plugin_handle->cls, + buf, + buf_size, + confirmation_cb, + NULL))) { fprintf (stderr, "Could not execute the wire transfer\n"); plugin_handle->prepare_wire_transfer_cancel (plugin_handle->cls, - ph); + ph); plugin_handle->execute_wire_transfer_cancel (plugin_handle->cls, - eh); + eh); GNUNET_SCHEDULER_shutdown (); } @@ -235,14 +235,14 @@ execute_wire_transfer () return; } if (NULL == (ph = plugin_handle->prepare_wire_transfer - (plugin_handle->cls, - account_section, - destination_account_url, - &a, - "http://exchange.example.com/", - &wtid, /* Any value will do. */ - prepare_cb, - NULL))) + (plugin_handle->cls, + account_section, + destination_account_url, + &a, + "http://exchange.example.com/", + &wtid, /* Any value will do. */ + prepare_cb, + NULL))) { fprintf (stderr, "Could not prepare the wire transfer\n"); @@ -269,20 +269,20 @@ execute_history () GNUNET_assert (GNUNET_OK == GNUNET_STRINGS_string_to_data (since_when, - strlen (since_when), - since_when_bin, - bin_len)); + strlen (since_when), + since_when_bin, + bin_len)); } if (NULL == plugin_handle->get_history - (plugin_handle->cls, - account_section, - TALER_BANK_DIRECTION_BOTH, - since_when_bin, - bin_len, - -10, - history_cb, - NULL)) + (plugin_handle->cls, + account_section, + TALER_BANK_DIRECTION_BOTH, + since_when_bin, + bin_len, + -10, + history_cb, + NULL)) { fprintf (stderr, "Could not request the transaction history.\n"); @@ -327,10 +327,10 @@ run (void *cls, } if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string - (cfg, - account_section, - "plugin", - &plugin_name)) + (cfg, + account_section, + "plugin", + &plugin_name)) { fprintf (stderr, "Could not find the 'plugin' value under %s\n", @@ -353,7 +353,7 @@ run (void *cls, execute_wire_transfer (); else fprintf (stderr, - "Please give either --history/-H or --transfer/t\n"); + "Please give either --history/-H or --transfer/t\n"); GNUNET_SCHEDULER_add_shutdown (&do_shutdown, NULL); @@ -422,13 +422,13 @@ main (int argc, "WARNING", NULL)); /* filename */ ret = GNUNET_PROGRAM_run - (argc, - argv, - "taler-wire", - "CLI bank client.", - options, - &run, - NULL); + (argc, + argv, + "taler-wire", + "CLI bank client.", + options, + &run, + NULL); if (GNUNET_OK != ret) return ret; return global_ret; diff --git a/src/exchange/taler-exchange-aggregator.c b/src/exchange/taler-exchange-aggregator.c index 9b1c7e3ee..b84c837e5 100644 --- a/src/exchange/taler-exchange-aggregator.c +++ b/src/exchange/taler-exchange-aggregator.c @@ -287,7 +287,8 @@ static int reserves_idle; * Note: do not change here, Postgres requires us to hard-code the * LIMIT in the prepared statement. */ -static unsigned int aggregation_limit = TALER_EXCHANGEDB_MATCHING_DEPOSITS_LIMIT; +static unsigned int aggregation_limit = + TALER_EXCHANGEDB_MATCHING_DEPOSITS_LIMIT; @@ -347,13 +348,13 @@ update_fees (struct WireAccount *wa, p = p->next) { qs = db_plugin->insert_wire_fee (db_plugin->cls, - session, - wa->wire_plugin->method, - p->start_date, - p->end_date, - &p->wire_fee, - &p->closing_fee, - &p->master_sig); + session, + wa->wire_plugin->method, + p->start_date, + p->end_date, + &p->wire_fee, + &p->closing_fee, + &p->master_sig); if (qs < 0) { TALER_EXCHANGEDB_fees_free (wa->af); @@ -486,8 +487,9 @@ shutdown_task (void *cls) { if (NULL != wpd->eh) { - wpd->wa->wire_plugin->execute_wire_transfer_cancel (wpd->wa->wire_plugin->cls, - wpd->eh); + wpd->wa->wire_plugin->execute_wire_transfer_cancel ( + wpd->wa->wire_plugin->cls, + wpd->eh); wpd->eh = NULL; } db_plugin->rollback (db_plugin->cls, @@ -499,8 +501,9 @@ shutdown_task (void *cls) { if (NULL != au->ph) { - au->wa->wire_plugin->prepare_wire_transfer_cancel (au->wa->wire_plugin->cls, - au->ph); + au->wa->wire_plugin->prepare_wire_transfer_cancel ( + au->wa->wire_plugin->cls, + au->ph); au->ph = NULL; } db_plugin->rollback (db_plugin->cls, @@ -509,8 +512,9 @@ shutdown_task (void *cls) } if (NULL != ctc) { - ctc->wa->wire_plugin->prepare_wire_transfer_cancel (ctc->wa->wire_plugin->cls, - ctc->ph); + ctc->wa->wire_plugin->prepare_wire_transfer_cancel ( + ctc->wa->wire_plugin->cls, + ctc->ph); ctc->ph = NULL; db_plugin->rollback (db_plugin->cls, ctc->session); @@ -613,12 +617,12 @@ exchange_serve_process_config () */ static int refund_by_coin_cb (void *cls, - const struct TALER_MerchantPublicKeyP *merchant_pub, - const struct TALER_MerchantSignatureP *merchant_sig, - const struct GNUNET_HashCode *h_contract, - uint64_t rtransaction_id, - const struct TALER_Amount *amount_with_fee, - const struct TALER_Amount *refund_fee) + const struct TALER_MerchantPublicKeyP *merchant_pub, + const struct TALER_MerchantSignatureP *merchant_sig, + const struct GNUNET_HashCode *h_contract, + uint64_t rtransaction_id, + const struct TALER_Amount *amount_with_fee, + const struct TALER_Amount *refund_fee) { struct AggregationUnit *aux = cls; @@ -632,8 +636,8 @@ refund_by_coin_cb (void *cls, return GNUNET_OK; /* different contract */ if (GNUNET_OK != TALER_amount_subtract (&aux->total_amount, - &aux->total_amount, - amount_with_fee)) + &aux->total_amount, + amount_with_fee)) { GNUNET_break (0); return GNUNET_SYSERR; @@ -680,17 +684,17 @@ deposit_cb (void *cls, GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Fatally malformed record at row %llu over %s\n", (unsigned long long) row_id, - TALER_amount2s (amount_with_fee)); + TALER_amount2s (amount_with_fee)); return GNUNET_DB_STATUS_HARD_ERROR; } au->row_id = row_id; au->h_contract = h_contract_terms; qs = db_plugin->select_refunds_by_coin (db_plugin->cls, - au->session, - coin_pub, - &refund_by_coin_cb, - au); + au->session, + coin_pub, + &refund_by_coin_cb, + au); au->h_contract = NULL; if (0 > qs) { @@ -738,8 +742,8 @@ deposit_cb (void *cls, au->execution_time = GNUNET_TIME_absolute_get (); (void) GNUNET_TIME_round_abs (&au->execution_time); qs = update_fees (au->wa, - au->execution_time, - au->session); + au->execution_time, + au->session); if (qs <= 0) { if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs) @@ -750,17 +754,17 @@ deposit_cb (void *cls, au->wire_fee = au->wa->af->wire_fee; qs = db_plugin->insert_aggregation_tracking (db_plugin->cls, - au->session, - &au->wtid, - row_id); + au->session, + &au->wtid, + row_id); if (qs <= 0) { GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); return qs; } qs = db_plugin->mark_deposit_done (db_plugin->cls, - au->session, - row_id); + au->session, + row_id); if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != qs) { GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); @@ -811,13 +815,13 @@ aggregate_cb (void *cls, GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Fatally malformed record at %llu over amount %s\n", (unsigned long long) row_id, - TALER_amount2s (amount_with_fee)); + TALER_amount2s (amount_with_fee)); return GNUNET_DB_STATUS_HARD_ERROR; } /* add to total */ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Adding transaction amount %s to aggregation\n", - TALER_amount2s (&delta)); + "Adding transaction amount %s to aggregation\n", + TALER_amount2s (&delta)); if (GNUNET_OK != TALER_amount_add (&au->total_amount, &au->total_amount, @@ -832,10 +836,10 @@ aggregate_cb (void *cls, au->h_contract = h_contract_terms; qs = db_plugin->select_refunds_by_coin (db_plugin->cls, - au->session, - coin_pub, - &refund_by_coin_cb, - au); + au->session, + coin_pub, + &refund_by_coin_cb, + au); au->h_contract = NULL; if (0 > qs) { @@ -857,25 +861,25 @@ aggregate_cb (void *cls, au->additional_rows[au->rows_offset++] = row_id; /* insert into aggregation tracking table */ qs = db_plugin->insert_aggregation_tracking (db_plugin->cls, - au->session, - &au->wtid, - row_id); + au->session, + &au->wtid, + row_id); if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != qs) { GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); return qs; } qs = db_plugin->mark_deposit_done (db_plugin->cls, - au->session, - row_id); + au->session, + row_id); if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != qs) { GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); return qs; } GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Added row %llu with %s to aggregation\n", - (unsigned long long) row_id, + "Added row %llu with %s to aggregation\n", + (unsigned long long) row_id, TALER_amount2s (&delta)); return GNUNET_DB_STATUS_SUCCESS_ONE_RESULT; } @@ -958,8 +962,8 @@ commit_or_warn (struct TALER_EXCHANGEDB_Session *session) */ static void prepare_close_cb (void *cls, - const char *buf, - size_t buf_size) + const char *buf, + size_t buf_size) { enum GNUNET_DB_QueryStatus qs; @@ -984,10 +988,10 @@ prepare_close_cb (void *cls, /* Commit our intention to execute the wire transfer! */ qs = db_plugin->wire_prepare_data_insert (db_plugin->cls, - ctc->session, - ctc->method, - buf, - buf_size); + ctc->session, + ctc->method, + buf, + buf_size); if (GNUNET_DB_STATUS_HARD_ERROR == qs) { GNUNET_break (0); @@ -1021,7 +1025,7 @@ prepare_close_cb (void *cls, GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Reserve closure committed, running transfer\n"); task = GNUNET_SCHEDULER_add_now (&run_transfers, - NULL); + NULL); } @@ -1059,10 +1063,10 @@ struct ExpiredReserveContext */ static enum GNUNET_DB_QueryStatus expired_reserve_cb (void *cls, - const struct TALER_ReservePublicKeyP *reserve_pub, - const struct TALER_Amount *left, - const char *account_details, - struct GNUNET_TIME_Absolute expiration_date) + const struct TALER_ReservePublicKeyP *reserve_pub, + const struct TALER_Amount *left, + const char *account_details, + struct GNUNET_TIME_Absolute expiration_date) { struct ExpiredReserveContext *erc = cls; struct TALER_EXCHANGEDB_Session *session = erc->session; @@ -1090,8 +1094,8 @@ expired_reserve_cb (void *cls, /* lookup `closing_fee` */ qs = update_fees (wa, - now, - session); + now, + session); if (qs <= 0) { if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs) @@ -1106,8 +1110,8 @@ expired_reserve_cb (void *cls, /* calculate transfer amount */ ret = TALER_amount_subtract (&amount_without_fee, - left, - closing_fee); + left, + closing_fee); if ( (GNUNET_SYSERR == ret) || (GNUNET_NO == ret) ) { @@ -1122,21 +1126,21 @@ expired_reserve_cb (void *cls, /* NOTE: sizeof (*reserve_pub) == sizeof (wtid) right now, but to be future-compatible, we use the memset + min construction */ memset (&wtid, - 0, - sizeof (wtid)); + 0, + sizeof (wtid)); memcpy (&wtid, - reserve_pub, - GNUNET_MIN (sizeof (wtid), - sizeof (*reserve_pub))); + reserve_pub, + GNUNET_MIN (sizeof (wtid), + sizeof (*reserve_pub))); qs = db_plugin->insert_reserve_closed (db_plugin->cls, - session, - reserve_pub, - now, - account_details, - &wtid, - left, - closing_fee); + session, + reserve_pub, + now, + account_details, + &wtid, + left, + closing_fee); GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Closing reserve %s over %s (%d, %d)\n", @@ -1149,8 +1153,8 @@ expired_reserve_cb (void *cls, { /* success, perform wire transfer */ if (GNUNET_SYSERR == - wa->wire_plugin->amount_round (wa->wire_plugin->cls, - &amount_without_fee)) + wa->wire_plugin->amount_round (wa->wire_plugin->cls, + &amount_without_fee)) { GNUNET_break (0); global_ret = GNUNET_SYSERR; @@ -1164,12 +1168,12 @@ expired_reserve_cb (void *cls, ctc->ph = wa->wire_plugin->prepare_wire_transfer (wa->wire_plugin->cls, wa->section_name, - account_details, - &amount_without_fee, - exchange_base_url, - &wtid, - &prepare_close_cb, - ctc); + account_details, + &amount_without_fee, + exchange_base_url, + &wtid, + &prepare_close_cb, + ctc); if (NULL == ctc->ph) { GNUNET_break (0); @@ -1233,7 +1237,7 @@ run_reserve_closures (void *cls) session); if (GNUNET_OK != db_plugin->start (db_plugin->cls, - session, + session, "aggregator reserve closures")) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, @@ -1247,10 +1251,10 @@ run_reserve_closures (void *cls) now = GNUNET_TIME_absolute_get (); (void) GNUNET_TIME_round_abs (&now); qs = db_plugin->get_expired_reserves (db_plugin->cls, - session, - now, - &expired_reserve_cb, - &erc); + session, + now, + &expired_reserve_cb, + &erc); switch (qs) { case GNUNET_DB_STATUS_HARD_ERROR: @@ -1264,7 +1268,7 @@ run_reserve_closures (void *cls) db_plugin->rollback (db_plugin->cls, session); task = GNUNET_SCHEDULER_add_now (&run_reserve_closures, - NULL); + NULL); return; case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: GNUNET_log (GNUNET_ERROR_TYPE_INFO, @@ -1273,14 +1277,14 @@ run_reserve_closures (void *cls) db_plugin->rollback (db_plugin->cls, session); task = GNUNET_SCHEDULER_add_now (&run_aggregation, - NULL); + NULL); return; case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT: if (GNUNET_YES == erc.async_cont) break; (void) commit_or_warn (session); task = GNUNET_SCHEDULER_add_now (&run_reserve_closures, - NULL); + NULL); return; } } @@ -1307,7 +1311,7 @@ run_aggregation (void *cls) if (0 == (++swap % 2)) { task = GNUNET_SCHEDULER_add_now (&run_reserve_closures, - NULL); + NULL); return; } GNUNET_log (GNUNET_ERROR_TYPE_INFO, @@ -1333,9 +1337,9 @@ run_aggregation (void *cls) au = GNUNET_new (struct AggregationUnit); au->session = session; qs = db_plugin->get_ready_deposit (db_plugin->cls, - session, - &deposit_cb, - au); + session, + &deposit_cb, + au); if (0 >= qs) { cleanup_au (); @@ -1354,7 +1358,7 @@ run_aggregation (void *cls) /* should re-try immediately */ swap--; /* do not count failed attempts */ task = GNUNET_SCHEDULER_add_now (&run_aggregation, - NULL); + NULL); return; } GNUNET_log (GNUNET_ERROR_TYPE_INFO, @@ -1368,15 +1372,15 @@ run_aggregation (void *cls) else { if ( (GNUNET_NO == reserves_idle) || - (GNUNET_YES == test_mode) ) - /* Possibly more to on reserves, go for it immediately */ - task = GNUNET_SCHEDULER_add_now (&run_reserve_closures, - NULL); + (GNUNET_YES == test_mode) ) + /* Possibly more to on reserves, go for it immediately */ + task = GNUNET_SCHEDULER_add_now (&run_reserve_closures, + NULL); else - /* nothing to do, sleep for a minute and try again */ - task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES, - &run_aggregation, - NULL); + /* nothing to do, sleep for a minute and try again */ + task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES, + &run_aggregation, + NULL); } return; } @@ -1386,12 +1390,12 @@ run_aggregation (void *cls) "Found ready deposit for %s, aggregating\n", TALER_B2S (&au->merchant_pub)); qs = db_plugin->iterate_matching_deposits (db_plugin->cls, - session, - &au->h_wire, - &au->merchant_pub, - &aggregate_cb, - au, - aggregation_limit); + session, + &au->h_wire, + &au->merchant_pub, + &aggregate_cb, + au, + aggregation_limit); if ( (GNUNET_DB_STATUS_HARD_ERROR == qs) || (GNUNET_YES == au->failed) ) { @@ -1412,7 +1416,7 @@ run_aggregation (void *cls) db_plugin->rollback (db_plugin->cls, session); task = GNUNET_SCHEDULER_add_now (&run_aggregation, - NULL); + NULL); return; } @@ -1431,8 +1435,8 @@ run_aggregation (void *cls) { GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Aggregate value too low for transfer (%d/%s)\n", - qs, - TALER_amount2s (&au->final_amount)); + qs, + TALER_amount2s (&au->final_amount)); /* Rollback ongoing transaction, as we will not use the respective WTID and thus need to remove the tracking data */ db_plugin->rollback (db_plugin->cls, @@ -1454,35 +1458,35 @@ run_aggregation (void *cls) } /* Mark transactions by row_id as minor */ qs = db_plugin->mark_deposit_tiny (db_plugin->cls, - session, - au->row_id); + session, + au->row_id); if (0 <= qs) { - for (unsigned int i=0;irows_offset;i++) + for (unsigned int i = 0; irows_offset; i++) { qs = db_plugin->mark_deposit_tiny (db_plugin->cls, - session, - au->additional_rows[i]); - if (0 > qs) - break; + session, + au->additional_rows[i]); + if (0 > qs) + break; } } if (GNUNET_DB_STATUS_SOFT_ERROR == qs) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Serialization issue, trying again later!\n"); + "Serialization issue, trying again later!\n"); db_plugin->rollback (db_plugin->cls, - session); + session); cleanup_au (); /* start again */ task = GNUNET_SCHEDULER_add_now (&run_aggregation, - NULL); + NULL); return; } if (GNUNET_DB_STATUS_HARD_ERROR == qs) { db_plugin->rollback (db_plugin->cls, - session); + session); cleanup_au (); GNUNET_SCHEDULER_shutdown (); return; @@ -1509,14 +1513,15 @@ run_aggregation (void *cls) char *url; url = TALER_JSON_wire_to_payto (au->wire); - au->ph = au->wa->wire_plugin->prepare_wire_transfer (au->wa->wire_plugin->cls, - au->wa->section_name, - url, - &au->final_amount, - exchange_base_url, - &au->wtid, - &prepare_cb, - au); + au->ph = au->wa->wire_plugin->prepare_wire_transfer ( + au->wa->wire_plugin->cls, + au->wa->section_name, + url, + &au->final_amount, + exchange_base_url, + &au->wtid, + &prepare_cb, + au); GNUNET_free (url); } if (NULL == au->ph) @@ -1563,24 +1568,24 @@ prepare_cb (void *cls, } GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Storing %u bytes of wire prepare data\n", - (unsigned int) buf_size); + "Storing %u bytes of wire prepare data\n", + (unsigned int) buf_size); /* Commit our intention to execute the wire transfer! */ qs = db_plugin->wire_prepare_data_insert (db_plugin->cls, - session, - au->wa->wire_plugin->method, - buf, - buf_size); + session, + au->wa->wire_plugin->method, + buf, + buf_size); /* Commit the WTID data to 'wire_out' to finally satisfy aggregation table constraints */ if (qs >= 0) qs = db_plugin->store_wire_transfer_out (db_plugin->cls, - session, - au->execution_time, - &au->wtid, - au->wire, + session, + au->execution_time, + &au->wtid, + au->wire, au->wa->section_name, - &au->final_amount); + &au->final_amount); cleanup_au (); if (GNUNET_DB_STATUS_SOFT_ERROR == qs) { @@ -1672,8 +1677,8 @@ wire_confirm_cb (void *cls, return; } qs = db_plugin->wire_prepare_data_mark_finished (db_plugin->cls, - session, - wpd->row_id); + session, + wpd->row_id); if (0 >= qs) { GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); @@ -1683,7 +1688,7 @@ wire_confirm_cb (void *cls, { /* try again */ task = GNUNET_SCHEDULER_add_now (&run_aggregation, - NULL); + NULL); } else { @@ -1759,11 +1764,12 @@ wire_prepare_cb (void *cls, wpd = NULL; return; } - wpd->eh = wpd->wa->wire_plugin->execute_wire_transfer (wpd->wa->wire_plugin->cls, - buf, - buf_size, - &wire_confirm_cb, - NULL); + wpd->eh = wpd->wa->wire_plugin->execute_wire_transfer ( + wpd->wa->wire_plugin->cls, + buf, + buf_size, + &wire_confirm_cb, + NULL); if (NULL == wpd->eh) { GNUNET_break (0); /* why? how to best recover? */ @@ -1821,13 +1827,13 @@ run_transfers (void *cls) wpd = GNUNET_new (struct WirePrepareData); wpd->session = session; qs = db_plugin->wire_prepare_data_get (db_plugin->cls, - session, - &wire_prepare_cb, - NULL); + session, + &wire_prepare_cb, + NULL); if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qs) return; /* continues in #wire_prepare_cb() */ db_plugin->rollback (db_plugin->cls, - session); + session); GNUNET_free (wpd); wpd = NULL; switch (qs) @@ -1840,7 +1846,7 @@ run_transfers (void *cls) case GNUNET_DB_STATUS_SOFT_ERROR: /* try again */ task = GNUNET_SCHEDULER_add_now (&run_transfers, - NULL); + NULL); return; case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: /* no more prepared wire transfers, go back to aggregation! */ @@ -1910,9 +1916,9 @@ main (int argc, { struct GNUNET_GETOPT_CommandLineOption options[] = { GNUNET_GETOPT_option_flag ('t', - "test", - "run in test mode and exit when idle", - &test_mode), + "test", + "run in test mode and exit when idle", + &test_mode), GNUNET_GETOPT_option_version (VERSION "-" VCS_VERSION), GNUNET_GETOPT_OPTION_END }; @@ -1923,7 +1929,8 @@ main (int argc, if (GNUNET_OK != GNUNET_PROGRAM_run (argc, argv, "taler-exchange-aggregator", - gettext_noop ("background process that aggregates and executes wire transfers to merchants"), + gettext_noop ( + "background process that aggregates and executes wire transfers to merchants"), options, &run, NULL)) { diff --git a/src/exchange/taler-exchange-httpd.c b/src/exchange/taler-exchange-httpd.c index b30b19c3f..cfeaf0ee8 100644 --- a/src/exchange/taler-exchange-httpd.c +++ b/src/exchange/taler-exchange-httpd.c @@ -194,7 +194,7 @@ is_valid_correlation_id (const char *correlation_id) if (strlen (correlation_id) >= 64) return GNUNET_NO; for (int i = 0; i < strlen (correlation_id); i++) - if (!(isalnum (correlation_id[i]) || correlation_id[i] == '-')) + if (! (isalnum (correlation_id[i]) || (correlation_id[i] == '-'))) return GNUNET_NO; return GNUNET_YES; } @@ -223,193 +223,191 @@ handle_mhd_request (void *cls, size_t *upload_data_size, void **con_cls) { - static struct TEH_RequestHandler handlers[] = - { - /* Landing page, tell humans to go away. */ - { "/", MHD_HTTP_METHOD_GET, "text/plain", - "Hello, I'm the Taler exchange. This HTTP server is not for humans.\n", 0, - &TEH_MHD_handler_static_response, MHD_HTTP_OK }, - /* /robots.txt: disallow everything */ - { "/robots.txt", MHD_HTTP_METHOD_GET, "text/plain", - "User-agent: *\nDisallow: /\n", 0, - &TEH_MHD_handler_static_response, MHD_HTTP_OK }, - /* AGPL licensing page, redirect to source. As per the AGPL-license, - every deployment is required to offer the user a download of the - source. We make this easy by including a redirect to the source - here. */ - { "/agpl", MHD_HTTP_METHOD_GET, "text/plain", - NULL, 0, - &TEH_MHD_handler_agpl_redirect, MHD_HTTP_FOUND }, - - /* Return key material and fundamental properties for this exchange */ - { "/keys", MHD_HTTP_METHOD_GET, "application/json", - NULL, 0, - &TEH_KS_handler_keys, MHD_HTTP_OK }, - { "/keys", NULL, "text/plain", - "Only GET is allowed", 0, - &TEH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, - - /* Requests for wiring information */ - { "/wire", MHD_HTTP_METHOD_GET, "application/json", - NULL, 0, - &TEH_WIRE_handler_wire, MHD_HTTP_OK }, - { "/wire", NULL, "text/plain", - "Only GET is allowed", 0, - &TEH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, - - /* Withdrawing coins / interaction with reserves */ - { "/reserve/status", MHD_HTTP_METHOD_GET, "application/json", - NULL, 0, - &TEH_RESERVE_handler_reserve_status, MHD_HTTP_OK }, - { "/reserve/status", NULL, "text/plain", - "Only GET is allowed", 0, - &TEH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, - - { "/reserve/withdraw", MHD_HTTP_METHOD_POST, "application/json", - NULL, 0, - &TEH_RESERVE_handler_reserve_withdraw, MHD_HTTP_OK }, - { "/reserve/withdraw", NULL, "text/plain", - "Only POST is allowed", 0, - &TEH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, - - /* Depositing coins */ - { "/deposit", MHD_HTTP_METHOD_POST, "application/json", - NULL, 0, - &TEH_DEPOSIT_handler_deposit, MHD_HTTP_OK }, - { "/deposit", NULL, "text/plain", - "Only POST is allowed", 0, - &TEH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, - - /* Refunding coins */ - { "/refund", MHD_HTTP_METHOD_POST, "application/json", - NULL, 0, - &TEH_REFUND_handler_refund, MHD_HTTP_OK }, - { "/refund", NULL, "text/plain", - "Only POST is allowed", 0, - &TEH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, - - /* Dealing with change */ - { "/refresh/melt", MHD_HTTP_METHOD_POST, "application/json", - NULL, 0, - &TEH_REFRESH_handler_refresh_melt, MHD_HTTP_OK }, - { "/refresh/melt", NULL, "text/plain", - "Only POST is allowed", 0, - &TEH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, - - { "/refresh/reveal", MHD_HTTP_METHOD_POST, "application/json", - NULL, 0, - &TEH_REFRESH_handler_refresh_reveal, MHD_HTTP_OK }, - { "/refresh/reveal", NULL, "text/plain", - "Only POST is allowed", 0, - &TEH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, - - { "/refresh/reveal", MHD_HTTP_METHOD_POST, "application/json", - NULL, 0, - &TEH_REFRESH_handler_refresh_reveal, MHD_HTTP_OK }, - { "/refresh/reveal", NULL, "text/plain", - "Only POST is allowed", 0, - &TEH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, - - { "/refresh/link", MHD_HTTP_METHOD_GET, "application/json", - NULL, 0, - &TEH_REFRESH_handler_refresh_link, MHD_HTTP_OK }, - { "/refresh/link", NULL, "text/plain", - "Only GET is allowed", 0, - &TEH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, - - { "/track/transfer", MHD_HTTP_METHOD_GET, "application/json", - NULL, 0, - &TEH_TRACKING_handler_track_transfer, MHD_HTTP_OK }, - { "/track/transfer", NULL, "text/plain", - "Only GET is allowed", 0, - &TEH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, - { "/track/transaction", MHD_HTTP_METHOD_POST, "application/json", - NULL, 0, - &TEH_TRACKING_handler_track_transaction, MHD_HTTP_OK }, - { "/track/transaction", NULL, "text/plain", - "Only POST is allowed", 0, - &TEH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, - - { "/payback", MHD_HTTP_METHOD_POST, "application/json", - NULL, 0, - &TEH_PAYBACK_handler_payback, MHD_HTTP_OK }, - { "/refresh/link", NULL, "text/plain", - "Only GET is allowed", 0, - &TEH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, + static struct TEH_RequestHandler handlers[] = { + /* Landing page, tell humans to go away. */ + { "/", MHD_HTTP_METHOD_GET, "text/plain", + "Hello, I'm the Taler exchange. This HTTP server is not for humans.\n", 0, + &TEH_MHD_handler_static_response, MHD_HTTP_OK }, + /* /robots.txt: disallow everything */ + { "/robots.txt", MHD_HTTP_METHOD_GET, "text/plain", + "User-agent: *\nDisallow: /\n", 0, + &TEH_MHD_handler_static_response, MHD_HTTP_OK }, + /* AGPL licensing page, redirect to source. As per the AGPL-license, + every deployment is required to offer the user a download of the + source. We make this easy by including a redirect to the source + here. */ + { "/agpl", MHD_HTTP_METHOD_GET, "text/plain", + NULL, 0, + &TEH_MHD_handler_agpl_redirect, MHD_HTTP_FOUND }, + + /* Return key material and fundamental properties for this exchange */ + { "/keys", MHD_HTTP_METHOD_GET, "application/json", + NULL, 0, + &TEH_KS_handler_keys, MHD_HTTP_OK }, + { "/keys", NULL, "text/plain", + "Only GET is allowed", 0, + &TEH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, + + /* Requests for wiring information */ + { "/wire", MHD_HTTP_METHOD_GET, "application/json", + NULL, 0, + &TEH_WIRE_handler_wire, MHD_HTTP_OK }, + { "/wire", NULL, "text/plain", + "Only GET is allowed", 0, + &TEH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, + + /* Withdrawing coins / interaction with reserves */ + { "/reserve/status", MHD_HTTP_METHOD_GET, "application/json", + NULL, 0, + &TEH_RESERVE_handler_reserve_status, MHD_HTTP_OK }, + { "/reserve/status", NULL, "text/plain", + "Only GET is allowed", 0, + &TEH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, + + { "/reserve/withdraw", MHD_HTTP_METHOD_POST, "application/json", + NULL, 0, + &TEH_RESERVE_handler_reserve_withdraw, MHD_HTTP_OK }, + { "/reserve/withdraw", NULL, "text/plain", + "Only POST is allowed", 0, + &TEH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, + + /* Depositing coins */ + { "/deposit", MHD_HTTP_METHOD_POST, "application/json", + NULL, 0, + &TEH_DEPOSIT_handler_deposit, MHD_HTTP_OK }, + { "/deposit", NULL, "text/plain", + "Only POST is allowed", 0, + &TEH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, + + /* Refunding coins */ + { "/refund", MHD_HTTP_METHOD_POST, "application/json", + NULL, 0, + &TEH_REFUND_handler_refund, MHD_HTTP_OK }, + { "/refund", NULL, "text/plain", + "Only POST is allowed", 0, + &TEH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, + + /* Dealing with change */ + { "/refresh/melt", MHD_HTTP_METHOD_POST, "application/json", + NULL, 0, + &TEH_REFRESH_handler_refresh_melt, MHD_HTTP_OK }, + { "/refresh/melt", NULL, "text/plain", + "Only POST is allowed", 0, + &TEH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, + + { "/refresh/reveal", MHD_HTTP_METHOD_POST, "application/json", + NULL, 0, + &TEH_REFRESH_handler_refresh_reveal, MHD_HTTP_OK }, + { "/refresh/reveal", NULL, "text/plain", + "Only POST is allowed", 0, + &TEH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, + + { "/refresh/reveal", MHD_HTTP_METHOD_POST, "application/json", + NULL, 0, + &TEH_REFRESH_handler_refresh_reveal, MHD_HTTP_OK }, + { "/refresh/reveal", NULL, "text/plain", + "Only POST is allowed", 0, + &TEH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, + + { "/refresh/link", MHD_HTTP_METHOD_GET, "application/json", + NULL, 0, + &TEH_REFRESH_handler_refresh_link, MHD_HTTP_OK }, + { "/refresh/link", NULL, "text/plain", + "Only GET is allowed", 0, + &TEH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, + + { "/track/transfer", MHD_HTTP_METHOD_GET, "application/json", + NULL, 0, + &TEH_TRACKING_handler_track_transfer, MHD_HTTP_OK }, + { "/track/transfer", NULL, "text/plain", + "Only GET is allowed", 0, + &TEH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, + { "/track/transaction", MHD_HTTP_METHOD_POST, "application/json", + NULL, 0, + &TEH_TRACKING_handler_track_transaction, MHD_HTTP_OK }, + { "/track/transaction", NULL, "text/plain", + "Only POST is allowed", 0, + &TEH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, + + { "/payback", MHD_HTTP_METHOD_POST, "application/json", + NULL, 0, + &TEH_PAYBACK_handler_payback, MHD_HTTP_OK }, + { "/refresh/link", NULL, "text/plain", + "Only GET is allowed", 0, + &TEH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, #if HAVE_DEVELOPER - /* Client crypto-interoperability test functions */ - { "/test", MHD_HTTP_METHOD_POST, "application/json", - NULL, 0, - &TEH_TEST_handler_test, MHD_HTTP_OK }, - { "/test", NULL, "text/plain", - "Only POST is allowed", 0, - &TEH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, - - { "/test/base32", MHD_HTTP_METHOD_POST, "application/json", - NULL, 0, - &TEH_TEST_handler_test_base32, MHD_HTTP_OK }, - { "/test/base32", NULL, "text/plain", - "Only POST is allowed", 0, - &TEH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, - - { "/test/encrypt", MHD_HTTP_METHOD_POST, "application/json", - NULL, 0, - &TEH_TEST_handler_test_encrypt, MHD_HTTP_OK }, - { "/test/encrypt", NULL, "text/plain", - "Only POST is allowed", 0, - &TEH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, - - { "/test/hkdf", MHD_HTTP_METHOD_POST, "application/json", - NULL, 0, - &TEH_TEST_handler_test_hkdf, MHD_HTTP_OK }, - { "/test/hkdf", NULL, "text/plain", - "Only POST is allowed", 0, - &TEH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, - - { "/test/ecdhe", MHD_HTTP_METHOD_POST, "application/json", - NULL, 0, - &TEH_TEST_handler_test_ecdhe, MHD_HTTP_OK }, - { "/test/ecdhe", NULL, "text/plain", - "Only POST is allowed", 0, - &TEH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, - - { "/test/eddsa", MHD_HTTP_METHOD_POST, "application/json", - NULL, 0, - &TEH_TEST_handler_test_eddsa, MHD_HTTP_OK }, - { "/test/eddsa", NULL, "text/plain", - "Only POST is allowed", 0, - &TEH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, - - { "/test/rsa/get", MHD_HTTP_METHOD_GET, "application/json", - NULL, 0, - &TEH_TEST_handler_test_rsa_get, MHD_HTTP_OK }, - { "/test/rsa/get", NULL, "text/plain", - "Only GET is allowed", 0, - &TEH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, - - { "/test/rsa/sign", MHD_HTTP_METHOD_POST, "application/json", - NULL, 0, - &TEH_TEST_handler_test_rsa_sign, MHD_HTTP_OK }, - { "/test/rsa/sign", NULL, "text/plain", - "Only POST is allowed", 0, - &TEH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, - - { "/test/transfer", MHD_HTTP_METHOD_POST, "application/json", - NULL, 0, - &TEH_TEST_handler_test_transfer, MHD_HTTP_OK }, - { "/test/transfer", NULL, "text/plain", - "Only POST is allowed", 0, - &TEH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, + /* Client crypto-interoperability test functions */ + { "/test", MHD_HTTP_METHOD_POST, "application/json", + NULL, 0, + &TEH_TEST_handler_test, MHD_HTTP_OK }, + { "/test", NULL, "text/plain", + "Only POST is allowed", 0, + &TEH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, + + { "/test/base32", MHD_HTTP_METHOD_POST, "application/json", + NULL, 0, + &TEH_TEST_handler_test_base32, MHD_HTTP_OK }, + { "/test/base32", NULL, "text/plain", + "Only POST is allowed", 0, + &TEH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, + + { "/test/encrypt", MHD_HTTP_METHOD_POST, "application/json", + NULL, 0, + &TEH_TEST_handler_test_encrypt, MHD_HTTP_OK }, + { "/test/encrypt", NULL, "text/plain", + "Only POST is allowed", 0, + &TEH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, + + { "/test/hkdf", MHD_HTTP_METHOD_POST, "application/json", + NULL, 0, + &TEH_TEST_handler_test_hkdf, MHD_HTTP_OK }, + { "/test/hkdf", NULL, "text/plain", + "Only POST is allowed", 0, + &TEH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, + + { "/test/ecdhe", MHD_HTTP_METHOD_POST, "application/json", + NULL, 0, + &TEH_TEST_handler_test_ecdhe, MHD_HTTP_OK }, + { "/test/ecdhe", NULL, "text/plain", + "Only POST is allowed", 0, + &TEH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, + + { "/test/eddsa", MHD_HTTP_METHOD_POST, "application/json", + NULL, 0, + &TEH_TEST_handler_test_eddsa, MHD_HTTP_OK }, + { "/test/eddsa", NULL, "text/plain", + "Only POST is allowed", 0, + &TEH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, + + { "/test/rsa/get", MHD_HTTP_METHOD_GET, "application/json", + NULL, 0, + &TEH_TEST_handler_test_rsa_get, MHD_HTTP_OK }, + { "/test/rsa/get", NULL, "text/plain", + "Only GET is allowed", 0, + &TEH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, + + { "/test/rsa/sign", MHD_HTTP_METHOD_POST, "application/json", + NULL, 0, + &TEH_TEST_handler_test_rsa_sign, MHD_HTTP_OK }, + { "/test/rsa/sign", NULL, "text/plain", + "Only POST is allowed", 0, + &TEH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, + + { "/test/transfer", MHD_HTTP_METHOD_POST, "application/json", + NULL, 0, + &TEH_TEST_handler_test_transfer, MHD_HTTP_OK }, + { "/test/transfer", NULL, "text/plain", + "Only POST is allowed", 0, + &TEH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, #endif - { NULL, NULL, NULL, NULL, 0, 0 } - }; - static struct TEH_RequestHandler h404 = - { - "", NULL, "text/html", - "404: not found", 0, - &TEH_MHD_handler_static_response, MHD_HTTP_NOT_FOUND - }; + { NULL, NULL, NULL, NULL, 0, 0 } + }; + static struct TEH_RequestHandler h404 = { + "", NULL, "text/html", + "404: not found", 0, + &TEH_MHD_handler_static_response, MHD_HTTP_NOT_FOUND + }; struct TEH_RequestHandler *rh; struct ExchangeHttpRequestClosure *ecls = *con_cls; int ret; @@ -430,8 +428,9 @@ handle_mhd_request (void *cls, if ((NULL != correlation_id) && (GNUNET_YES != is_valid_correlation_id (correlation_id))) { - GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "illegal incoming correlation ID\n"); - correlation_id = NULL; + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, + "illegal incoming correlation ID\n"); + correlation_id = NULL; } } @@ -452,7 +451,7 @@ handle_mhd_request (void *cls, if (0 == strcasecmp (method, MHD_HTTP_METHOD_HEAD)) method = MHD_HTTP_METHOD_GET; /* treat HEAD as GET here, MHD will do the rest */ - for (unsigned int i=0;NULL != handlers[i].url;i++) + for (unsigned int i = 0; NULL != handlers[i].url; i++) { rh = &handlers[i]; if ( (0 == strcasecmp (url, @@ -675,8 +674,10 @@ exchange_serve_process_config () } if (GNUNET_OK != GNUNET_CRYPTO_eddsa_public_key_from_string (TEH_master_public_key_str, - strlen (TEH_master_public_key_str), - &TEH_master_public_key.eddsa_pub)) + strlen ( + TEH_master_public_key_str), + &TEH_master_public_key. + eddsa_pub)) { fprintf (stderr, "Invalid master public key given in exchange configuration."); @@ -764,7 +765,7 @@ run_fake_client () sizeof (ports), "%u", serve_port); - if (0 == (cld = fork())) + if (0 == (cld = fork ())) { GNUNET_break (0 == close (0)); GNUNET_break (0 == dup2 (fd, 0)); @@ -824,7 +825,7 @@ connection_done (void *cls, if (NULL == input_filename) return; /* We signal ourselves to terminate. */ - if (0 != kill (getpid(), + if (0 != kill (getpid (), SIGTERM)) GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "kill"); @@ -992,21 +993,24 @@ write_stats () (unsigned long long) pid); fh = GNUNET_DISK_file_open (s, - (GNUNET_DISK_OPEN_WRITE | - GNUNET_DISK_OPEN_TRUNCATE | - GNUNET_DISK_OPEN_CREATE), - (GNUNET_DISK_PERM_USER_READ | - GNUNET_DISK_PERM_USER_WRITE)); + (GNUNET_DISK_OPEN_WRITE + | GNUNET_DISK_OPEN_TRUNCATE + | GNUNET_DISK_OPEN_CREATE), + (GNUNET_DISK_PERM_USER_READ + | GNUNET_DISK_PERM_USER_WRITE)); GNUNET_assert (NULL != fh); GNUNET_free (s); /* Collect stats, summed up for all threads */ - GNUNET_assert (0 == getrusage(RUSAGE_SELF, &usage)); + GNUNET_assert (0 == getrusage (RUSAGE_SELF, &usage)); GNUNET_asprintf (&s, "time_exchange sys %llu user %llu\n", \ - (unsigned long long) (usage.ru_stime.tv_sec * 1000 * 1000 + usage.ru_stime.tv_usec), - (unsigned long long) (usage.ru_utime.tv_sec * 1000 * 1000 + usage.ru_utime.tv_usec)); - GNUNET_assert (GNUNET_SYSERR != GNUNET_DISK_file_write_blocking (fh, s, strlen (s))); + (unsigned long long) (usage.ru_stime.tv_sec * 1000 * 1000 + + usage.ru_stime.tv_usec), + (unsigned long long) (usage.ru_utime.tv_sec * 1000 * 1000 + + usage.ru_utime.tv_usec)); + GNUNET_assert (GNUNET_SYSERR != GNUNET_DISK_file_write_blocking (fh, s, + strlen (s))); GNUNET_free (s); GNUNET_assert (GNUNET_OK == GNUNET_DISK_file_close (fh)); @@ -1038,19 +1042,20 @@ main (int argc, "init-db", "create database tables and indicies if necessary", &init_db), - GNUNET_GETOPT_option_uint ('t', - "timeout", - "SECONDS", - "after how long do connections timeout by default (in seconds)", - &connection_timeout), + GNUNET_GETOPT_option_uint ('t', + "timeout", + "SECONDS", + "after how long do connections timeout by default (in seconds)", + &connection_timeout), #if HAVE_DEVELOPER - GNUNET_GETOPT_option_filename ('f', - "file-input", - "FILENAME", - "run in test-mode using FILENAME as the HTTP request to process", - &input_filename), + GNUNET_GETOPT_option_filename ('f', + "file-input", + "FILENAME", + "run in test-mode using FILENAME as the HTTP request to process", + &input_filename), #endif - GNUNET_GETOPT_option_help ("HTTP server providing a RESTful API to access a Taler exchange"), + GNUNET_GETOPT_option_help ( + "HTTP server providing a RESTful API to access a Taler exchange"), GNUNET_GETOPT_option_loglevel (&loglev), GNUNET_GETOPT_option_logfile (&logfile), GNUNET_GETOPT_option_version (VERSION "-" VCS_VERSION), @@ -1077,7 +1082,7 @@ main (int argc, GNUNET_CONFIGURATION_load (cfg, cfgfile)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - _("Malformed configuration file `%s', exit ...\n"), + _ ("Malformed configuration file `%s', exit ...\n"), cfgfile); GNUNET_free_non_null (cfgfile); return 1; @@ -1092,9 +1097,9 @@ main (int argc, listen_fds = getenv ("LISTEN_FDS"); if ( (NULL != listen_pid) && (NULL != listen_fds) && - (getpid() == strtol (listen_pid, - NULL, - 10)) && + (getpid () == strtol (listen_pid, + NULL, + 10)) && (1 == strtoul (listen_fds, NULL, 10)) ) @@ -1131,7 +1136,10 @@ main (int argc, } mhd - = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY | MHD_USE_PIPE_FOR_SHUTDOWN | MHD_USE_DEBUG | MHD_USE_DUAL_STACK | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_TCP_FASTOPEN, + = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY | MHD_USE_PIPE_FOR_SHUTDOWN + | MHD_USE_DEBUG | MHD_USE_DUAL_STACK + | MHD_USE_INTERNAL_POLLING_THREAD + | MHD_USE_TCP_FASTOPEN, (-1 == fh) ? serve_port : 0, NULL, NULL, &handle_mhd_request, NULL, @@ -1139,7 +1147,8 @@ main (int argc, MHD_OPTION_LISTEN_BACKLOG_SIZE, (unsigned int) 1024, MHD_OPTION_LISTEN_SOCKET, fh, MHD_OPTION_EXTERNAL_LOGGER, &handle_mhd_logs, NULL, - MHD_OPTION_NOTIFY_COMPLETED, &handle_mhd_completion_callback, NULL, + MHD_OPTION_NOTIFY_COMPLETED, + &handle_mhd_completion_callback, NULL, MHD_OPTION_CONNECTION_TIMEOUT, connection_timeout, #if HAVE_DEVELOPER MHD_OPTION_NOTIFY_CONNECTION, &connection_done, NULL, @@ -1225,7 +1234,8 @@ main (int argc, close it here */ GNUNET_break (0 == close (sock)); while (0 != MHD_get_daemon_info (mhd, - MHD_DAEMON_INFO_CURRENT_CONNECTIONS)->num_connections) + MHD_DAEMON_INFO_CURRENT_CONNECTIONS)-> + num_connections) sleep (1); /* Now we're really done, practice clean shutdown */ MHD_stop_daemon (mhd); diff --git a/src/exchange/taler-exchange-httpd_db.c b/src/exchange/taler-exchange-httpd_db.c index 3b9dc36b5..37bd23792 100644 --- a/src/exchange/taler-exchange-httpd_db.c +++ b/src/exchange/taler-exchange-httpd_db.c @@ -105,7 +105,8 @@ TEH_DB_run_transaction (struct MHD_Connection *connection, } TEH_plugin->preflight (TEH_plugin->cls, session); - for (unsigned int retries = 0;retries < MAX_TRANSACTION_COMMIT_RETRIES; retries++) + for (unsigned int retries = 0; retries < MAX_TRANSACTION_COMMIT_RETRIES; + retries++) { enum GNUNET_DB_QueryStatus qs; @@ -131,7 +132,7 @@ TEH_DB_run_transaction (struct MHD_Connection *connection, return GNUNET_SYSERR; if (0 <= qs) qs = TEH_plugin->commit (TEH_plugin->cls, - session); + session); if (GNUNET_DB_STATUS_HARD_ERROR == qs) { if (NULL != mhd_ret) @@ -150,7 +151,7 @@ TEH_DB_run_transaction (struct MHD_Connection *connection, MAX_TRANSACTION_COMMIT_RETRIES); if (NULL != mhd_ret) *mhd_ret = TEH_RESPONSE_reply_commit_error (connection, - TALER_EC_DB_COMMIT_FAILED_ON_RETRY); + TALER_EC_DB_COMMIT_FAILED_ON_RETRY); return GNUNET_SYSERR; } @@ -167,7 +168,8 @@ TEH_DB_run_transaction (struct MHD_Connection *connection, */ // FIXME: maybe move to another module, i.e. exchangedb??? int -TEH_DB_calculate_transaction_list_totals (struct TALER_EXCHANGEDB_TransactionList *tl, +TEH_DB_calculate_transaction_list_totals (struct + TALER_EXCHANGEDB_TransactionList *tl, const struct TALER_Amount *off, struct TALER_Amount *ret) { @@ -177,7 +179,8 @@ TEH_DB_calculate_transaction_list_totals (struct TALER_EXCHANGEDB_TransactionLis GNUNET_assert (GNUNET_OK == TALER_amount_get_zero (spent.currency, &refunded)); - for (struct TALER_EXCHANGEDB_TransactionList *pos = tl; NULL != pos; pos = pos->next) + for (struct TALER_EXCHANGEDB_TransactionList *pos = tl; NULL != pos; pos = + pos->next) { switch (pos->type) { diff --git a/src/exchange/taler-exchange-httpd_db.h b/src/exchange/taler-exchange-httpd_db.h index 091421bb4..c63b3668b 100644 --- a/src/exchange/taler-exchange-httpd_db.h +++ b/src/exchange/taler-exchange-httpd_db.h @@ -80,9 +80,9 @@ TEH_DB_know_coin_transaction (void *cls, */ typedef enum GNUNET_DB_QueryStatus (*TEH_DB_TransactionCallback)(void *cls, - struct MHD_Connection *connection, - struct TALER_EXCHANGEDB_Session *session, - int *mhd_ret); + struct MHD_Connection *connection, + struct TALER_EXCHANGEDB_Session *session, + int *mhd_ret); /** @@ -102,9 +102,9 @@ typedef enum GNUNET_DB_QueryStatus int TEH_DB_run_transaction (struct MHD_Connection *connection, const char *name, - int *mhd_ret, - TEH_DB_TransactionCallback cb, - void *cb_cls); + int *mhd_ret, + TEH_DB_TransactionCallback cb, + void *cb_cls); /** @@ -119,9 +119,10 @@ TEH_DB_run_transaction (struct MHD_Connection *connection, */ // FIXME: maybe move to another module, i.e. exchangedb??? int -TEH_DB_calculate_transaction_list_totals (struct TALER_EXCHANGEDB_TransactionList *tl, - const struct TALER_Amount *off, - struct TALER_Amount *ret); +TEH_DB_calculate_transaction_list_totals (struct + TALER_EXCHANGEDB_TransactionList *tl, + const struct TALER_Amount *off, + struct TALER_Amount *ret); #endif diff --git a/src/exchange/taler-exchange-httpd_deposit.c b/src/exchange/taler-exchange-httpd_deposit.c index c19ad4b1e..9e96dfd81 100644 --- a/src/exchange/taler-exchange-httpd_deposit.c +++ b/src/exchange/taler-exchange-httpd_deposit.c @@ -56,13 +56,13 @@ */ static int reply_deposit_success (struct MHD_Connection *connection, - const struct TALER_CoinSpendPublicKeyP *coin_pub, - const struct GNUNET_HashCode *h_wire, - const struct GNUNET_HashCode *h_contract_terms, - struct GNUNET_TIME_Absolute timestamp, - struct GNUNET_TIME_Absolute refund_deadline, - const struct TALER_MerchantPublicKeyP *merchant, - const struct TALER_Amount *amount_without_fee) + const struct TALER_CoinSpendPublicKeyP *coin_pub, + const struct GNUNET_HashCode *h_wire, + const struct GNUNET_HashCode *h_contract_terms, + struct GNUNET_TIME_Absolute timestamp, + struct GNUNET_TIME_Absolute refund_deadline, + const struct TALER_MerchantPublicKeyP *merchant, + const struct TALER_Amount *amount_without_fee) { struct TALER_DepositConfirmationPS dc; struct TALER_ExchangePublicKeyP pub; @@ -92,7 +92,8 @@ reply_deposit_success (struct MHD_Connection *connection, "{s:s, s:o, s:o}", "status", "DEPOSIT_OK", "sig", GNUNET_JSON_from_data_auto (&sig), - "pub", GNUNET_JSON_from_data_auto (&pub)); + "pub", GNUNET_JSON_from_data_auto ( + &pub)); } @@ -197,7 +198,7 @@ deposit_transaction (void *cls, TEH_plugin->free_coin_transaction_list (TEH_plugin->cls, tl); *mhd_ret = TEH_RESPONSE_reply_internal_db_error (connection, - TALER_EC_DEPOSIT_HISTORY_DB_ERROR); + TALER_EC_DEPOSIT_HISTORY_DB_ERROR); return GNUNET_DB_STATUS_HARD_ERROR; } /* Check that cost of all transactions is smaller than @@ -206,10 +207,10 @@ deposit_transaction (void *cls, &dc->value)) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - "Deposited coin has insufficient funds left!\n"); + "Deposited coin has insufficient funds left!\n"); *mhd_ret = TEH_RESPONSE_reply_coin_insufficient_funds (connection, - TALER_EC_DEPOSIT_INSUFFICIENT_FUNDS, - tl); + TALER_EC_DEPOSIT_INSUFFICIENT_FUNDS, + tl); TEH_plugin->free_coin_transaction_list (TEH_plugin->cls, tl); return GNUNET_DB_STATUS_HARD_ERROR; @@ -223,7 +224,7 @@ deposit_transaction (void *cls, { TALER_LOG_WARNING ("Failed to store /deposit information in database\n"); *mhd_ret = TEH_RESPONSE_reply_internal_db_error (connection, - TALER_EC_DEPOSIT_STORE_DB_ERROR); + TALER_EC_DEPOSIT_STORE_DB_ERROR); } return qs; } @@ -291,7 +292,7 @@ verify_and_execute_deposit (struct MHD_Connection *connection, { TEH_KS_release (mks); return TEH_RESPONSE_reply_internal_db_error (connection, - TALER_EC_DEPOSIT_DB_DENOMINATION_KEY_UNKNOWN); + TALER_EC_DEPOSIT_DB_DENOMINATION_KEY_UNKNOWN); } TALER_amount_ntoh (&dc.value, &dki->issue.properties.value); @@ -341,20 +342,20 @@ check_timestamp_current (struct GNUNET_TIME_Absolute ts) if (r.rel_value_us > tolerance.rel_value_us) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Deposit timestamp too old: %llu vs %llu > %llu\n", - (unsigned long long) ts.abs_value_us, - (unsigned long long) GNUNET_TIME_absolute_get().abs_value_us, - (unsigned long long) tolerance.rel_value_us); + "Deposit timestamp too old: %llu vs %llu > %llu\n", + (unsigned long long) ts.abs_value_us, + (unsigned long long) GNUNET_TIME_absolute_get ().abs_value_us, + (unsigned long long) tolerance.rel_value_us); return GNUNET_SYSERR; } r = GNUNET_TIME_absolute_get_remaining (ts); if (r.rel_value_us > tolerance.rel_value_us) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Deposit timestamp too new: %llu vs %llu < - %llu\n", - (unsigned long long) ts.abs_value_us, - (unsigned long long) GNUNET_TIME_absolute_get().abs_value_us, - (unsigned long long) tolerance.rel_value_us); + "Deposit timestamp too new: %llu vs %llu < - %llu\n", + (unsigned long long) ts.abs_value_us, + (unsigned long long) GNUNET_TIME_absolute_get ().abs_value_us, + (unsigned long long) tolerance.rel_value_us); return GNUNET_SYSERR; } return GNUNET_OK; @@ -394,7 +395,8 @@ TEH_DEPOSIT_handler_deposit (struct TEH_RequestHandler *rh, struct GNUNET_JSON_Specification spec[] = { GNUNET_JSON_spec_json ("wire", &wire), TALER_JSON_spec_amount ("contribution", &deposit.amount_with_fee), - GNUNET_JSON_spec_fixed_auto ("denom_pub_hash", &deposit.coin.denom_pub_hash), + GNUNET_JSON_spec_fixed_auto ("denom_pub_hash", + &deposit.coin.denom_pub_hash), TALER_JSON_spec_denomination_signature ("ub_sig", &deposit.coin.denom_sig), GNUNET_JSON_spec_fixed_auto ("coin_pub", &deposit.coin.coin_pub), GNUNET_JSON_spec_fixed_auto ("merchant_pub", &deposit.merchant_pub), @@ -402,8 +404,10 @@ TEH_DEPOSIT_handler_deposit (struct TEH_RequestHandler *rh, GNUNET_JSON_spec_fixed_auto ("H_wire", &deposit.h_wire), GNUNET_JSON_spec_fixed_auto ("coin_sig", &deposit.csig), GNUNET_JSON_spec_absolute_time ("timestamp", &deposit.timestamp), - GNUNET_JSON_spec_absolute_time ("refund_deadline", &deposit.refund_deadline), - GNUNET_JSON_spec_absolute_time ("wire_transfer_deadline", &deposit.wire_deadline), + GNUNET_JSON_spec_absolute_time ("refund_deadline", + &deposit.refund_deadline), + GNUNET_JSON_spec_absolute_time ("wire_transfer_deadline", + &deposit.wire_deadline), GNUNET_JSON_spec_end () }; @@ -435,7 +439,7 @@ TEH_DEPOSIT_handler_deposit (struct TEH_RequestHandler *rh, GNUNET_break_op (0); GNUNET_JSON_parse_free (spec); return TEH_RESPONSE_reply_arg_invalid (connection, - TALER_EC_DEPOSIT_REFUND_DEADLINE_AFTER_WIRE_DEADLINE, + TALER_EC_DEPOSIT_REFUND_DEADLINE_AFTER_WIRE_DEADLINE, "refund_deadline"); } @@ -456,17 +460,18 @@ TEH_DEPOSIT_handler_deposit (struct TEH_RequestHandler *rh, GNUNET_break_op (0); GNUNET_JSON_parse_free (spec); return TEH_RESPONSE_reply_arg_invalid (connection, - TALER_EC_DEPOSIT_INVALID_TIMESTAMP, + TALER_EC_DEPOSIT_INVALID_TIMESTAMP, "timestamp"); } if (GNUNET_OK != TALER_JSON_merchant_wire_signature_hash (wire, &my_h_wire)) { - TALER_LOG_WARNING ("Failed to parse JSON wire format specification for /deposit request\n"); + TALER_LOG_WARNING ( + "Failed to parse JSON wire format specification for /deposit request\n"); GNUNET_JSON_parse_free (spec); return TEH_RESPONSE_reply_arg_invalid (connection, - TALER_EC_DEPOSIT_INVALID_WIRE_FORMAT_JSON, + TALER_EC_DEPOSIT_INVALID_WIRE_FORMAT_JSON, "wire"); } if (0 != GNUNET_memcmp (&deposit.h_wire, @@ -475,7 +480,7 @@ TEH_DEPOSIT_handler_deposit (struct TEH_RequestHandler *rh, /* Client hashed contract differently than we did, reject */ GNUNET_JSON_parse_free (spec); return TEH_RESPONSE_reply_arg_invalid (connection, - TALER_EC_DEPOSIT_INVALID_WIRE_FORMAT_CONTRACT_HASH_CONFLICT, + TALER_EC_DEPOSIT_INVALID_WIRE_FORMAT_CONTRACT_HASH_CONFLICT, "H_wire"); } @@ -499,7 +504,7 @@ TEH_DEPOSIT_handler_deposit (struct TEH_RequestHandler *rh, TALER_LOG_WARNING ("Unknown denomination key in /deposit request\n"); GNUNET_JSON_parse_free (spec); return TEH_RESPONSE_reply_arg_unknown (connection, - TALER_EC_DEPOSIT_DENOMINATION_KEY_UNKNOWN, + TALER_EC_DEPOSIT_DENOMINATION_KEY_UNKNOWN, "denom_pub"); } TALER_amount_ntoh (&deposit.deposit_fee, @@ -513,7 +518,7 @@ TEH_DEPOSIT_handler_deposit (struct TEH_RequestHandler *rh, TEH_KS_release (key_state); GNUNET_JSON_parse_free (spec); return TEH_RESPONSE_reply_signature_invalid (connection, - TALER_EC_DEPOSIT_DENOMINATION_SIGNATURE_INVALID, + TALER_EC_DEPOSIT_DENOMINATION_SIGNATURE_INVALID, "ub_sig"); } TALER_amount_ntoh (&deposit.deposit_fee, @@ -526,7 +531,7 @@ TEH_DEPOSIT_handler_deposit (struct TEH_RequestHandler *rh, GNUNET_break_op (0); GNUNET_JSON_parse_free (spec); return TEH_RESPONSE_reply_external_error (connection, - TALER_EC_DEPOSIT_NEGATIVE_VALUE_AFTER_FEE, + TALER_EC_DEPOSIT_NEGATIVE_VALUE_AFTER_FEE, "deposited amount smaller than depositing fee"); } diff --git a/src/exchange/taler-exchange-httpd_keystate.c b/src/exchange/taler-exchange-httpd_keystate.c index 2252622d7..3c4e0e2a3 100644 --- a/src/exchange/taler-exchange-httpd_keystate.c +++ b/src/exchange/taler-exchange-httpd_keystate.c @@ -364,7 +364,7 @@ destroy_response_factory (struct ResponseFactoryContext *rfc) json_decref (rfc->sign_keys_array); rfc->sign_keys_array = NULL; } - for (unsigned int i=0;idenomkey_array_length;i++) + for (unsigned int i = 0; idenomkey_array_length; i++) { struct DenominationKeyEntry *dke = &rfc->denomkey_array[i]; struct AuditorSignature *as; @@ -438,9 +438,9 @@ ks_release (struct TEH_KS_StateHandle *key_state) { GNUNET_assert (0 < key_state->refcnt); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "KS release called (%p/%d)\n", - key_state, - key_state->refcnt); + "KS release called (%p/%d)\n", + key_state, + key_state->refcnt); key_state->refcnt--; if (0 == key_state->refcnt) { @@ -460,7 +460,7 @@ ks_release (struct TEH_KS_StateHandle *key_state) GNUNET_CONTAINER_multihashmap_destroy (key_state->revoked_map); key_state->revoked_map = NULL; } - for (unsigned int i=0;ikrd_array_length;i++) + for (unsigned int i = 0; ikrd_array_length; i++) { struct KeysResponseData *krd = &key_state->krd_array[i]; @@ -527,7 +527,8 @@ handle_signal (int signal_number) */ static json_t * denom_key_issue_to_json (const struct TALER_DenominationPublicKey *pk, - const struct TALER_EXCHANGEDB_DenominationKeyInformationP *dki) + const struct + TALER_EXCHANGEDB_DenominationKeyInformationP *dki) { struct TALER_Amount value; struct TALER_Amount fee_withdraw; @@ -550,13 +551,17 @@ denom_key_issue_to_json (const struct TALER_DenominationPublicKey *pk, "master_sig", GNUNET_JSON_from_data_auto (&dki->signature), "stamp_start", - GNUNET_JSON_from_time_abs (GNUNET_TIME_absolute_ntoh (dki->properties.start)), + GNUNET_JSON_from_time_abs (GNUNET_TIME_absolute_ntoh ( + dki->properties.start)), "stamp_expire_withdraw", - GNUNET_JSON_from_time_abs (GNUNET_TIME_absolute_ntoh (dki->properties.expire_withdraw)), + GNUNET_JSON_from_time_abs (GNUNET_TIME_absolute_ntoh ( + dki->properties.expire_withdraw)), "stamp_expire_deposit", - GNUNET_JSON_from_time_abs (GNUNET_TIME_absolute_ntoh (dki->properties.expire_deposit)), + GNUNET_JSON_from_time_abs (GNUNET_TIME_absolute_ntoh ( + dki->properties.expire_deposit)), "stamp_expire_legal", - GNUNET_JSON_from_time_abs (GNUNET_TIME_absolute_ntoh (dki->properties.expire_legal)), + GNUNET_JSON_from_time_abs (GNUNET_TIME_absolute_ntoh ( + dki->properties.expire_legal)), "denom_pub", GNUNET_JSON_from_rsa_public_key (pk->rsa_public_key), "value", @@ -582,7 +587,8 @@ denom_key_issue_to_json (const struct TALER_DenominationPublicKey *pk, */ static int store_in_map (struct GNUNET_CONTAINER_MultiHashMap *map, - const struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *dki) + const struct + TALER_EXCHANGEDB_DenominationKeyIssueInformation *dki) { struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *d2; int res; @@ -599,10 +605,11 @@ store_in_map (struct GNUNET_CONTAINER_MultiHashMap *map, = htonl (sizeof (struct TALER_DenominationKeyValidityPS)); denom_key_issue.master = TEH_master_public_key; if (GNUNET_SYSERR == - GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_MASTER_DENOMINATION_KEY_VALIDITY, - &denom_key_issue.purpose, - &dkip->signature.eddsa_signature, - &TEH_master_public_key.eddsa_pub)) + GNUNET_CRYPTO_eddsa_verify ( + TALER_SIGNATURE_MASTER_DENOMINATION_KEY_VALIDITY, + &denom_key_issue.purpose, + &dkip->signature.eddsa_signature, + &TEH_master_public_key.eddsa_pub)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Invalid signature on denomination key `%s'\n", @@ -610,7 +617,7 @@ store_in_map (struct GNUNET_CONTAINER_MultiHashMap *map, return GNUNET_SYSERR; } } - + d2 = GNUNET_new (struct TALER_EXCHANGEDB_DenominationKeyIssueInformation); d2->issue = dki->issue; if (NULL != dki->denom_priv.rsa_private_key) @@ -692,9 +699,9 @@ TALER_EXCHANGE_conf_duration_provide () */ static enum GNUNET_DB_QueryStatus add_revocations_transaction (void *cls, - struct MHD_Connection *connection, - struct TALER_EXCHANGEDB_Session *session, - int *mhd_ret) + struct MHD_Connection *connection, + struct TALER_EXCHANGEDB_Session *session, + int *mhd_ret) { struct AddRevocationContext *arc = cls; enum GNUNET_DB_QueryStatus qs; @@ -703,7 +710,8 @@ add_revocations_transaction (void *cls, qs = TEH_plugin->get_denomination_revocation (TEH_plugin->cls, session, - &arc->dki->issue.properties.denom_hash, + &arc->dki->issue.properties. + denom_hash, &master_sig, &rowid); if (0 > qs) @@ -712,7 +720,8 @@ add_revocations_transaction (void *cls, return qs; /* already exists == success */ return TEH_plugin->insert_denomination_revocation (TEH_plugin->cls, session, - &arc->dki->issue.properties.denom_hash, + &arc->dki->issue.properties + .denom_hash, arc->revocation_master_sig); } @@ -764,7 +773,8 @@ add_denomination_transaction (void *cls, static int reload_keys_denom_iter (void *cls, const char *alias, - const struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *dki) + const struct + TALER_EXCHANGEDB_DenominationKeyIssueInformation *dki) { struct ResponseFactoryContext *rfc = cls; struct TEH_KS_StateHandle *key_state = rfc->key_state; @@ -776,7 +786,8 @@ reload_keys_denom_iter (void *cls, "Loading denomination key `%s' (%s)\n", alias, GNUNET_h2s (&dki->issue.properties.denom_hash)); - expire_deposit = GNUNET_TIME_absolute_ntoh (dki->issue.properties.expire_deposit); + expire_deposit = GNUNET_TIME_absolute_ntoh ( + dki->issue.properties.expire_deposit); if (expire_deposit.abs_value_us < rfc->now.abs_value_us) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, @@ -846,8 +857,8 @@ reload_keys_denom_iter (void *cls, */ static int revocations_iter (void *cls, - const struct GNUNET_HashCode *denom_hash, - const struct TALER_MasterSignatureP *revocation_master_sig) + const struct GNUNET_HashCode *denom_hash, + const struct TALER_MasterSignatureP *revocation_master_sig) { struct ResponseFactoryContext *rfc = cls; struct TEH_KS_StateHandle *key_state = rfc->key_state; @@ -855,7 +866,7 @@ revocations_iter (void *cls, struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *dki; dki = GNUNET_CONTAINER_multihashmap_get (key_state->denomkey_map, - denom_hash); + denom_hash); if (NULL == dki) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, @@ -865,15 +876,16 @@ revocations_iter (void *cls, } GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "Adding denomination key `%s' to revocation set\n", - GNUNET_h2s (denom_hash)); + "Adding denomination key `%s' to revocation set\n", + GNUNET_h2s (denom_hash)); GNUNET_assert (GNUNET_YES == GNUNET_CONTAINER_multihashmap_remove (key_state->denomkey_map, denom_hash, dki)); GNUNET_assert (GNUNET_YES == GNUNET_CONTAINER_multihashmap_put (key_state->revoked_map, - &dki->issue.properties.denom_hash, + &dki->issue.properties. + denom_hash, dki, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); /* Try to insert revocation into DB */ @@ -881,19 +893,20 @@ revocations_iter (void *cls, arc.revocation_master_sig = revocation_master_sig; if (GNUNET_OK != TEH_DB_run_transaction (NULL, - "add denomination key revocation", - NULL, - &add_revocations_transaction, - &arc)) + "add denomination key revocation", + NULL, + &add_revocations_transaction, + &arc)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Failed to add revocation to database. This is fatal. Committing suicide via SIGTERM.\n"); + "Failed to add revocation to database. This is fatal. Committing suicide via SIGTERM.\n"); handle_signal (SIGTERM); return GNUNET_SYSERR; } GNUNET_assert (0 == - json_array_append_new (rfc->payback_array, - GNUNET_JSON_from_data_auto (denom_hash))); + json_array_append_new (rfc->payback_array, + GNUNET_JSON_from_data_auto ( + denom_hash))); return GNUNET_OK; } @@ -912,9 +925,11 @@ sign_key_issue_to_json (const struct TALER_ExchangeSigningKeyValidityPS *ski, return json_pack ("{s:o, s:o, s:o, s:o, s:o}", "stamp_start", - GNUNET_JSON_from_time_abs (GNUNET_TIME_absolute_ntoh (ski->start)), + GNUNET_JSON_from_time_abs (GNUNET_TIME_absolute_ntoh ( + ski->start)), "stamp_expire", - GNUNET_JSON_from_time_abs (GNUNET_TIME_absolute_ntoh (ski->expire)), + GNUNET_JSON_from_time_abs (GNUNET_TIME_absolute_ntoh ( + ski->expire)), "stamp_end", GNUNET_JSON_from_time_abs (GNUNET_TIME_absolute_ntoh (ski->end)), "master_sig", @@ -940,14 +955,16 @@ sign_key_issue_to_json (const struct TALER_ExchangeSigningKeyValidityPS *ski, static int reload_keys_sign_iter (void *cls, const char *filename, - const struct TALER_EXCHANGEDB_PrivateSigningKeyInformationP *ski) + const struct + TALER_EXCHANGEDB_PrivateSigningKeyInformationP *ski) { struct ResponseFactoryContext *rfc = cls; struct TEH_KS_StateHandle *key_state = rfc->key_state; struct GNUNET_TIME_Absolute now; struct GNUNET_TIME_Absolute horizon; - horizon = GNUNET_TIME_relative_to_absolute (TALER_EXCHANGE_conf_duration_provide ()); + horizon = GNUNET_TIME_relative_to_absolute ( + TALER_EXCHANGE_conf_duration_provide ()); if (GNUNET_TIME_absolute_ntoh (ski->issue.start).abs_value_us > horizon.abs_value_us) { @@ -977,7 +994,8 @@ reload_keys_sign_iter (void *cls, /* The signkey is valid at this time, check if it's more recent than what we have so far! */ - if ( (GNUNET_TIME_absolute_ntoh (key_state->current_sign_key_issue.issue.start).abs_value_us < + if ( (GNUNET_TIME_absolute_ntoh ( + key_state->current_sign_key_issue.issue.start).abs_value_us < GNUNET_TIME_absolute_ntoh (ski->issue.start).abs_value_us) && (GNUNET_TIME_absolute_ntoh (ski->issue.start).abs_value_us < now.abs_value_us) ) @@ -1034,7 +1052,7 @@ reload_auditor_iter (void *cls, } /* Filter the auditor information for those for which the keys actually match the denomination keys that are active right now */ - for (unsigned int i=0;idenomkey_array_length;j++) + for (unsigned int j = 0; jdenomkey_array_length; j++) { struct DenominationKeyEntry *dke = &rfc->denomkey_array[j]; struct AuditorSignature *as; if (0 != - memcmp (&dki[i].denom_hash, - &dke->dki->issue.properties.denom_hash, - sizeof (struct GNUNET_HashCode))) - continue; + memcmp (&dki[i].denom_hash, + &dke->dki->issue.properties.denom_hash, + sizeof (struct GNUNET_HashCode))) + continue; if (0 != memcmp (&dki[i], &dke->dki->issue.properties, @@ -1072,8 +1090,8 @@ reload_auditor_iter (void *cls, GNUNET_break (0); continue; } - as = GNUNET_malloc (sizeof (struct AuditorSignature) + - strlen (auditor_url) + 1); + as = GNUNET_malloc (sizeof (struct AuditorSignature) + + strlen (auditor_url) + 1); as->asig = asigs[i]; as->apub = *apub; as->auditor_url = (const char *) &as[1]; @@ -1090,8 +1108,8 @@ reload_auditor_iter (void *cls, { GNUNET_break (0); GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "DK `%s' is in active map, but not in array!?\n", - GNUNET_h2s (&dki[i].denom_hash)); + "DK `%s' is in active map, but not in array!?\n", + GNUNET_h2s (&dki[i].denom_hash)); } } return GNUNET_OK; @@ -1147,7 +1165,7 @@ denomkey_array_sort_comparator (const void *k1, if (d1.abs_value_us < d2.abs_value_us) return -1; if (d1.abs_value_us > d2.abs_value_us) - return 1; + return 1; return 0; } @@ -1164,15 +1182,15 @@ get_date_string (struct GNUNET_TIME_Absolute at, char *date) { static const char *const days[] = - { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" }; + { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" }; static const char *const mons[] = - { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", - "Nov", "Dec" - }; + { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", + "Nov", "Dec"}; struct tm now; time_t t; -#if !defined(HAVE_C11_GMTIME_S) && !defined(HAVE_W32_GMTIME_S) && !defined(HAVE_GMTIME_R) - struct tm* pNow; +#if ! defined(HAVE_C11_GMTIME_S) && ! defined(HAVE_W32_GMTIME_S) && \ + ! defined(HAVE_GMTIME_R) + struct tm*pNow; #endif date[0] = 0; @@ -1184,10 +1202,10 @@ get_date_string (struct GNUNET_TIME_Absolute at, if (0 != gmtime_s (&now, &t)) return; #elif defined(HAVE_GMTIME_R) - if (NULL == gmtime_r(&t, &now)) + if (NULL == gmtime_r (&t, &now)) return; #else - pNow = gmtime(&t); + pNow = gmtime (&t); if (NULL == pNow) return; now = *pNow; @@ -1364,7 +1382,7 @@ build_keys_response (const struct ResponseFactoryContext *rfc, auditors = GNUNET_CONTAINER_multihashmap_create (4, GNUNET_NO); - for (unsigned int i=denom_off;idenomkey_array_length;i++) + for (unsigned int i = denom_off; idenomkey_array_length; i++) { /* Add denomination key to the response */ const struct DenominationKeyEntry *dke @@ -1414,9 +1432,11 @@ build_keys_response (const struct ResponseFactoryContext *rfc, json_array_append_new (ae->ar, json_pack ("{s:o, s:o}", "denom_pub_h", - GNUNET_JSON_from_data_auto (denom_key_hash), + GNUNET_JSON_from_data_auto ( + denom_key_hash), "auditor_sig", - GNUNET_JSON_from_data_auto (&as->asig)))); + GNUNET_JSON_from_data_auto ( + &as->asig)))); } } @@ -1434,9 +1454,11 @@ build_keys_response (const struct ResponseFactoryContext *rfc, &ks.hc); rbc.hash_context = NULL; GNUNET_assert (GNUNET_OK == - GNUNET_CRYPTO_eddsa_sign (&rfc->key_state->current_sign_key_issue.signkey_priv.eddsa_priv, - &ks.purpose, - &sig.eddsa_signature)); + GNUNET_CRYPTO_eddsa_sign ( + &rfc->key_state->current_sign_key_issue.signkey_priv. + eddsa_priv, + &ks.purpose, + &sig.eddsa_signature)); if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_time (cfg, "exchangedb", @@ -1447,23 +1469,28 @@ build_keys_response (const struct ResponseFactoryContext *rfc, "exchangedb", "IDLE_RESERVE_EXPIRATION_TIME"); /* use default */ - reserve_closing_delay = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_WEEKS, - 4); + reserve_closing_delay = GNUNET_TIME_relative_multiply ( + GNUNET_TIME_UNIT_WEEKS, + 4); } /* Build /keys response */ keys = json_pack ("{s:s, s:o, s:o, s:O, s:O," " s:o, s:o, s:o, s:o, s:o}", /* 1-5 */ "version", TALER_PROTOCOL_VERSION, - "master_public_key", GNUNET_JSON_from_data_auto (&TEH_master_public_key), - "reserve_closing_delay", GNUNET_JSON_from_time_rel (reserve_closing_delay), + "master_public_key", GNUNET_JSON_from_data_auto ( + &TEH_master_public_key), + "reserve_closing_delay", GNUNET_JSON_from_time_rel ( + reserve_closing_delay), "signkeys", rfc->sign_keys_array, "payback", rfc->payback_array, /* 6-10 */ "denoms", rbc.denom_keys_array, "auditors", rbc.auditors_array, - "list_issue_date", GNUNET_JSON_from_time_abs (rfc->key_state->reload_time), - "eddsa_pub", GNUNET_JSON_from_data_auto (&rfc->key_state->current_sign_key_issue.issue.signkey_pub), + "list_issue_date", GNUNET_JSON_from_time_abs ( + rfc->key_state->reload_time), + "eddsa_pub", GNUNET_JSON_from_data_auto ( + &rfc->key_state->current_sign_key_issue.issue.signkey_pub), "eddsa_sig", GNUNET_JSON_from_data_auto (&sig)); if (NULL == keys) { @@ -1560,13 +1587,14 @@ build_keys_response (const struct ResponseFactoryContext *rfc, static void reload_public_denoms_cb (void *cls, const struct TALER_DenominationPublicKey *denom_pub, - const struct TALER_EXCHANGEDB_DenominationKeyInformationP *issue) + const struct + TALER_EXCHANGEDB_DenominationKeyInformationP *issue) { struct ResponseFactoryContext *rfc = cls; struct TALER_EXCHANGEDB_DenominationKeyIssueInformation dki; if (rfc->now.abs_value_us > GNUNET_TIME_absolute_ntoh - (issue->properties.expire_legal).abs_value_us) + (issue->properties.expire_legal).abs_value_us) { /* Expired key, discard. */ return; @@ -1672,9 +1700,9 @@ make_fresh_key_state (struct GNUNET_TIME_Absolute now) /* process revocations */ if (-1 == TALER_EXCHANGEDB_revocations_iterate (TEH_revocation_directory, - &TEH_master_public_key, - &revocations_iter, - &rfc)) + &TEH_master_public_key, + &revocations_iter, + &rfc)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to load denomination keys from `%s'.\n", @@ -1716,7 +1744,8 @@ make_fresh_key_state (struct GNUNET_TIME_Absolute now) /* Initialize and sort the `denomkey_array` */ rfc.denomkey_array - = GNUNET_new_array (GNUNET_CONTAINER_multihashmap_size (key_state->denomkey_map), + = GNUNET_new_array (GNUNET_CONTAINER_multihashmap_size ( + key_state->denomkey_map), struct DenominationKeyEntry); GNUNET_CONTAINER_multihashmap_iterate (key_state->denomkey_map, &initialize_denomkey_array, @@ -1733,16 +1762,16 @@ make_fresh_key_state (struct GNUNET_TIME_Absolute now) &reload_auditor_iter, &rfc); /* Sanity check: do we have auditors for all denomination keys? */ - for (unsigned int i=0;ias_head) GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - "Denomination key `%s' at %p not signed by any auditor!\n", - GNUNET_h2s (&dke->denom_key_hash), - dke); + "Denomination key `%s' at %p not signed by any auditor!\n", + GNUNET_h2s (&dke->denom_key_hash), + dke); } /* Determine size of `krd_array` by counting number of discrete @@ -1750,7 +1779,7 @@ make_fresh_key_state (struct GNUNET_TIME_Absolute now) last = GNUNET_TIME_UNIT_ZERO_ABS; key_state->krd_array_length = 0; off = 1; /* reserve one slot for the "no keys" response */ - for (unsigned int i=0;inext_reload = - GNUNET_TIME_absolute_min (GNUNET_TIME_absolute_ntoh (key_state->current_sign_key_issue.issue.expire), + GNUNET_TIME_absolute_min (GNUNET_TIME_absolute_ntoh ( + key_state->current_sign_key_issue.issue.expire), key_state->min_dk_expire); GNUNET_assert (0 != key_state->next_reload.abs_value_us); @@ -1777,7 +1807,7 @@ make_fresh_key_state (struct GNUNET_TIME_Absolute now) struct KeysResponseData); off = 0; last = GNUNET_TIME_UNIT_ZERO_ABS; - for (unsigned int i=0;irefcnt); + key_state, + key_state->refcnt); ks_release (key_state); GNUNET_assert (0 == pthread_mutex_unlock (&internal_key_state_mutex)); } @@ -1870,7 +1900,7 @@ TEH_KS_acquire_ (struct GNUNET_TIME_Absolute now, internal_key_state = NULL; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "KS released in acquire due to expiration\n"); + "KS released in acquire due to expiration\n"); ks_release (ks); rcd = 1; /* remember that we released 'internal_key_state' */ } @@ -1882,7 +1912,7 @@ TEH_KS_acquire_ (struct GNUNET_TIME_Absolute now, { GNUNET_assert (0 == pthread_mutex_unlock (&internal_key_state_mutex)); GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Failed to initialize key state\n"); + "Failed to initialize key state\n"); return NULL; } internal_key_state->refcnt += rcd; @@ -1892,16 +1922,16 @@ TEH_KS_acquire_ (struct GNUNET_TIME_Absolute now, { key_state->refcnt++; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "KS acquired at %s (%p/%d)\n", - location, - key_state, - key_state->refcnt); + "KS acquired at %s (%p/%d)\n", + location, + key_state, + key_state->refcnt); } else { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - "KS acquire failed at %s\n", - location); + "KS acquire failed at %s\n", + location); } GNUNET_assert (0 == pthread_mutex_unlock (&internal_key_state_mutex)); @@ -1920,17 +1950,20 @@ TEH_KS_acquire_ (struct GNUNET_TIME_Absolute now, * or NULL if denom_pub could not be found (or is not valid at this time for the given @a use) */ struct TALER_EXCHANGEDB_DenominationKeyIssueInformation * -TEH_KS_denomination_key_lookup_by_hash (const struct TEH_KS_StateHandle *key_state, - const struct GNUNET_HashCode *denom_pub_hash, +TEH_KS_denomination_key_lookup_by_hash (const struct + TEH_KS_StateHandle *key_state, + const struct + GNUNET_HashCode *denom_pub_hash, enum TEH_KS_DenominationKeyUse use) { struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *dki; struct GNUNET_TIME_Absolute now; const struct GNUNET_CONTAINER_MultiHashMap *map; - map = (TEH_KS_DKU_PAYBACK == use) ? key_state->revoked_map : key_state->denomkey_map; + map = (TEH_KS_DKU_PAYBACK == use) ? key_state->revoked_map : + key_state->denomkey_map; dki = GNUNET_CONTAINER_multihashmap_get (map, - denom_pub_hash); + denom_pub_hash); if ( (NULL == dki) && (TEH_KS_DKU_ZOMBIE == use)) dki = GNUNET_CONTAINER_multihashmap_get (key_state->revoked_map, denom_pub_hash); @@ -1941,8 +1974,8 @@ TEH_KS_denomination_key_lookup_by_hash (const struct TEH_KS_StateHandle *key_sta GNUNET_TIME_absolute_ntoh (dki->issue.properties.start).abs_value_us) { GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "Not returning DKI for %s, as start time is in the future\n", - GNUNET_h2s (denom_pub_hash)); + "Not returning DKI for %s, as start time is in the future\n", + GNUNET_h2s (denom_pub_hash)); return NULL; } now = GNUNET_TIME_absolute_get (); @@ -1950,48 +1983,52 @@ TEH_KS_denomination_key_lookup_by_hash (const struct TEH_KS_StateHandle *key_sta { case TEH_KS_DKU_WITHDRAW: if (now.abs_value_us > - GNUNET_TIME_absolute_ntoh (dki->issue.properties.expire_withdraw).abs_value_us) + GNUNET_TIME_absolute_ntoh ( + dki->issue.properties.expire_withdraw).abs_value_us) { GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "Not returning DKI for %s, as time to create coins has passed\n", - GNUNET_h2s (denom_pub_hash)); + "Not returning DKI for %s, as time to create coins has passed\n", + GNUNET_h2s (denom_pub_hash)); return NULL; } if (NULL == dki->denom_priv.rsa_private_key) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Not returning DKI of %s for WITHDRAW operation as we lack the private key, even though the withdraw period did not yet expire!\n", - GNUNET_h2s (denom_pub_hash)); + "Not returning DKI of %s for WITHDRAW operation as we lack the private key, even though the withdraw period did not yet expire!\n", + GNUNET_h2s (denom_pub_hash)); return NULL; } break; case TEH_KS_DKU_DEPOSIT: if (now.abs_value_us > - GNUNET_TIME_absolute_ntoh (dki->issue.properties.expire_deposit).abs_value_us) + GNUNET_TIME_absolute_ntoh ( + dki->issue.properties.expire_deposit).abs_value_us) { GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "Not returning DKI for %s, as time to spend coin has passed\n", - GNUNET_h2s (denom_pub_hash)); + "Not returning DKI for %s, as time to spend coin has passed\n", + GNUNET_h2s (denom_pub_hash)); return NULL; } break; case TEH_KS_DKU_PAYBACK: if (now.abs_value_us > - GNUNET_TIME_absolute_ntoh (dki->issue.properties.expire_deposit).abs_value_us) + GNUNET_TIME_absolute_ntoh ( + dki->issue.properties.expire_deposit).abs_value_us) { GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "Not returning DKI for %s, as time to payback coin has passed\n", - GNUNET_h2s (denom_pub_hash)); + "Not returning DKI for %s, as time to payback coin has passed\n", + GNUNET_h2s (denom_pub_hash)); return NULL; } break; case TEH_KS_DKU_ZOMBIE: if (now.abs_value_us > - GNUNET_TIME_absolute_ntoh (dki->issue.properties.expire_legal).abs_value_us) + GNUNET_TIME_absolute_ntoh ( + dki->issue.properties.expire_legal).abs_value_us) { GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "Not returning DKI for %s, as legal expiration of coin has passed\n", - GNUNET_h2s (denom_pub_hash)); + "Not returning DKI for %s, as legal expiration of coin has passed\n", + GNUNET_h2s (denom_pub_hash)); return NULL; } break; @@ -2113,7 +2150,7 @@ TEH_KS_loop (void) ret = GNUNET_SYSERR; break; } -read_again: + read_again: errno = 0; res = read (reload_pipe[0], &c, @@ -2206,14 +2243,15 @@ TEH_KS_sign (const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose, /* This *can* happen if the exchange's keys are not properly maintained. */ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - _("Cannot sign request, no valid keys available\n")); + _ ("Cannot sign request, no valid keys available\n")); return GNUNET_SYSERR; } *pub = key_state->current_sign_key_issue.issue.signkey_pub; GNUNET_assert (GNUNET_OK == - GNUNET_CRYPTO_eddsa_sign (&key_state->current_sign_key_issue.signkey_priv.eddsa_priv, - purpose, - &sig->eddsa_signature)); + GNUNET_CRYPTO_eddsa_sign ( + &key_state->current_sign_key_issue.signkey_priv.eddsa_priv, + purpose, + &sig->eddsa_signature)); TEH_KS_release (key_state); return GNUNET_OK; } diff --git a/src/exchange/taler-exchange-httpd_keystate.h b/src/exchange/taler-exchange-httpd_keystate.h index 6f5d338cb..7e2a659ef 100644 --- a/src/exchange/taler-exchange-httpd_keystate.h +++ b/src/exchange/taler-exchange-httpd_keystate.h @@ -69,7 +69,7 @@ TEH_KS_release_ (const char *location, * client via the "now" URL parameter of "/keys". * @return the key state */ -#define TEH_KS_acquire(now) TEH_KS_acquire_(now, __FUNCTION__) +#define TEH_KS_acquire(now) TEH_KS_acquire_ (now, __FUNCTION__) /** @@ -93,7 +93,8 @@ TEH_KS_free (void); * periods for a key differ, the caller must specify which * use is relevant for the current operation. */ -enum TEH_KS_DenominationKeyUse { +enum TEH_KS_DenominationKeyUse +{ /** * The key is to be used for a /reserve/withdraw or /refresh (exchange) @@ -113,7 +114,7 @@ enum TEH_KS_DenominationKeyUse { /** * The key is to be used for a /refresh/payback operation, - * i.e. it is an old coin that regained value from a + * i.e. it is an old coin that regained value from a * payback on a new coin derived from the old coin. */ TEH_KS_DKU_ZOMBIE @@ -132,8 +133,10 @@ enum TEH_KS_DenominationKeyUse { * or NULL if denom_pub could not be found (or is not valid at this time for the given @a use) */ struct TALER_EXCHANGEDB_DenominationKeyIssueInformation * -TEH_KS_denomination_key_lookup_by_hash (const struct TEH_KS_StateHandle *key_state, - const struct GNUNET_HashCode *denom_pub_hash, +TEH_KS_denomination_key_lookup_by_hash (const struct + TEH_KS_StateHandle *key_state, + const struct + GNUNET_HashCode *denom_pub_hash, enum TEH_KS_DenominationKeyUse use); diff --git a/src/exchange/taler-exchange-httpd_mhd.c b/src/exchange/taler-exchange-httpd_mhd.c index e76ada2cd..dfea44adb 100644 --- a/src/exchange/taler-exchange-httpd_mhd.c +++ b/src/exchange/taler-exchange-httpd_mhd.c @@ -45,10 +45,10 @@ */ int TEH_MHD_handler_static_response (struct TEH_RequestHandler *rh, - struct MHD_Connection *connection, - void **connection_cls, - const char *upload_data, - size_t *upload_data_size) + struct MHD_Connection *connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size) { struct MHD_Response *response; int ret; @@ -142,16 +142,16 @@ TEH_MHD_handler_agpl_redirect (struct TEH_RequestHandler *rh, */ int TEH_MHD_handler_send_json_pack_error (struct TEH_RequestHandler *rh, - struct MHD_Connection *connection, - void **connection_cls, - const char *upload_data, - size_t *upload_data_size) + struct MHD_Connection *connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size) { return TEH_RESPONSE_reply_json_pack (connection, - rh->response_code, - "{s:s}", - "error", - rh->data); + rh->response_code, + "{s:s}", + "error", + rh->data); } diff --git a/src/exchange/taler-exchange-httpd_parsing.c b/src/exchange/taler-exchange-httpd_parsing.c index d1a1e9df5..dc77d1822 100644 --- a/src/exchange/taler-exchange-httpd_parsing.c +++ b/src/exchange/taler-exchange-httpd_parsing.c @@ -33,7 +33,7 @@ /** * Maximum POST request size. */ -#define REQUEST_BUFFER_MAX (1024*1024) +#define REQUEST_BUFFER_MAX (1024 * 1024) @@ -80,21 +80,21 @@ TEH_PARSE_post_json (struct MHD_Connection *connection, 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; + (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; + (connection)) ? GNUNET_SYSERR : GNUNET_NO; case GNUNET_JSON_PR_JSON_INVALID: return (MHD_YES == TEH_RESPONSE_reply_invalid_json (connection)) - ? GNUNET_NO : GNUNET_SYSERR; + ? GNUNET_NO : GNUNET_SYSERR; case GNUNET_JSON_PR_SUCCESS: GNUNET_break (NULL != *json); return GNUNET_YES; @@ -149,9 +149,9 @@ TEH_PARSE_mhd_request_arg_data (struct MHD_Connection *connection, { return (MHD_NO == TEH_RESPONSE_reply_arg_missing (connection, - TALER_EC_PARAMETER_MISSING, - param_name)) - ? GNUNET_SYSERR : GNUNET_NO; + TALER_EC_PARAMETER_MISSING, + param_name)) + ? GNUNET_SYSERR : GNUNET_NO; } if (GNUNET_OK != GNUNET_STRINGS_string_to_data (str, @@ -160,9 +160,9 @@ TEH_PARSE_mhd_request_arg_data (struct MHD_Connection *connection, out_size)) return (MHD_NO == TEH_RESPONSE_reply_arg_invalid (connection, - TALER_EC_PARAMETER_MALFORMED, - param_name)) - ? GNUNET_SYSERR : GNUNET_NO; + TALER_EC_PARAMETER_MALFORMED, + param_name)) + ? GNUNET_SYSERR : GNUNET_NO; return GNUNET_OK; } @@ -203,10 +203,12 @@ TEH_PARSE_json_data (struct MHD_Connection *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, + "code", + (json_int_t) + TALER_EC_JSON_INVALID_WITH_DETAILS, "field", error_json_name, "line", (json_int_t) error_line)) - ? GNUNET_NO : GNUNET_SYSERR; + ? GNUNET_NO : GNUNET_SYSERR; return ret; } return GNUNET_YES; @@ -257,7 +259,7 @@ TEH_PARSE_json_array (struct MHD_Connection *connection, "{s:s, s:I}", "error", "parse error", "dimension", dim)) - ? GNUNET_NO : GNUNET_SYSERR; + ? GNUNET_NO : GNUNET_SYSERR; return ret; } ret = GNUNET_JSON_parse (root, @@ -275,7 +277,7 @@ TEH_PARSE_json_array (struct MHD_Connection *connection, "error", "parse error", "field", error_json_name, "line", (json_int_t) error_line)) - ? GNUNET_NO : GNUNET_SYSERR; + ? GNUNET_NO : GNUNET_SYSERR; return ret; } return GNUNET_YES; diff --git a/src/exchange/taler-exchange-httpd_payback.c b/src/exchange/taler-exchange-httpd_payback.c index 50c0ffdbc..468d69b3f 100644 --- a/src/exchange/taler-exchange-httpd_payback.c +++ b/src/exchange/taler-exchange-httpd_payback.c @@ -67,7 +67,8 @@ reply_payback_unknown (struct MHD_Connection *connection, static int reply_payback_refresh_success (struct MHD_Connection *connection, const struct TALER_CoinSpendPublicKeyP *coin_pub, - const struct TALER_CoinSpendPublicKeyP *old_coin_pub, + const struct + TALER_CoinSpendPublicKeyP *old_coin_pub, const struct TALER_Amount *amount, struct GNUNET_TIME_Absolute timestamp) { @@ -94,11 +95,17 @@ reply_payback_refresh_success (struct MHD_Connection *connection, return TEH_RESPONSE_reply_json_pack (connection, MHD_HTTP_OK, "{s:o, s:o, s:o, s:o, s:o}", - "old_coin_pub", GNUNET_JSON_from_data_auto (old_coin_pub), - "timestamp", GNUNET_JSON_from_time_abs (timestamp), - "amount", TALER_JSON_from_amount (amount), - "exchange_sig", GNUNET_JSON_from_data_auto (&sig), - "exchange_pub", GNUNET_JSON_from_data_auto (&pub)); + "old_coin_pub", + GNUNET_JSON_from_data_auto ( + old_coin_pub), + "timestamp", GNUNET_JSON_from_time_abs ( + timestamp), + "amount", TALER_JSON_from_amount ( + amount), + "exchange_sig", + GNUNET_JSON_from_data_auto (&sig), + "exchange_pub", + GNUNET_JSON_from_data_auto (&pub)); } @@ -142,11 +149,16 @@ reply_payback_success (struct MHD_Connection *connection, return TEH_RESPONSE_reply_json_pack (connection, MHD_HTTP_OK, "{s:o, s:o, s:o, s:o, s:o}", - "reserve_pub", GNUNET_JSON_from_data_auto (reserve_pub), - "timestamp", GNUNET_JSON_from_time_abs (timestamp), - "amount", TALER_JSON_from_amount (amount), - "exchange_sig", GNUNET_JSON_from_data_auto (&sig), - "exchange_pub", GNUNET_JSON_from_data_auto (&pub)); + "reserve_pub", + GNUNET_JSON_from_data_auto (reserve_pub), + "timestamp", GNUNET_JSON_from_time_abs ( + timestamp), + "amount", TALER_JSON_from_amount ( + amount), + "exchange_sig", + GNUNET_JSON_from_data_auto (&sig), + "exchange_pub", + GNUNET_JSON_from_data_auto (&pub)); } @@ -405,7 +417,8 @@ payback_transaction (void *cls, static int verify_and_execute_payback (struct MHD_Connection *connection, const struct TALER_CoinPublicInfo *coin, - const struct TALER_DenominationBlindingKeyP *coin_bks, + const struct + TALER_DenominationBlindingKeyP *coin_bks, const struct TALER_CoinSpendSignatureP *coin_sig, int refreshed) { @@ -432,7 +445,8 @@ verify_and_execute_payback (struct MHD_Connection *connection, if (NULL == dki) { TEH_KS_release (key_state); - TALER_LOG_WARNING ("Denomination key in /payback request not in payback mode\n"); + TALER_LOG_WARNING ( + "Denomination key in /payback request not in payback mode\n"); return TEH_RESPONSE_reply_arg_unknown (connection, TALER_EC_PAYBACK_DENOMINATION_KEY_UNKNOWN, "denom_pub"); @@ -527,16 +541,16 @@ verify_and_execute_payback (struct MHD_Connection *connection, return mhd_ret; } return (refreshed) - ? reply_payback_refresh_success (connection, - &coin->coin_pub, - &pc.target.old_coin_pub, - &pc.amount, - pc.now) - : reply_payback_success (connection, - &coin->coin_pub, - &pc.target.reserve_pub, - &pc.amount, - pc.now); + ? reply_payback_refresh_success (connection, + &coin->coin_pub, + &pc.target.old_coin_pub, + &pc.amount, + pc.now) + : reply_payback_success (connection, + &coin->coin_pub, + &pc.target.reserve_pub, + &pc.amount, + pc.now); } @@ -579,8 +593,8 @@ TEH_PAYBACK_handler_payback (struct TEH_RequestHandler *rh, GNUNET_JSON_spec_fixed_auto ("coin_sig", &coin_sig), GNUNET_JSON_spec_mark_optional - (GNUNET_JSON_spec_boolean ("refreshed", - &refreshed)), + (GNUNET_JSON_spec_boolean ("refreshed", + &refreshed)), GNUNET_JSON_spec_end () }; diff --git a/src/exchange/taler-exchange-httpd_refresh_link.c b/src/exchange/taler-exchange-httpd_refresh_link.c index b6712f75c..e5a332308 100644 --- a/src/exchange/taler-exchange-httpd_refresh_link.c +++ b/src/exchange/taler-exchange-httpd_refresh_link.c @@ -88,10 +88,12 @@ handle_link_data (void *cls, goto fail; json_object_set_new (obj, "denom_pub", - GNUNET_JSON_from_rsa_public_key (pos->denom_pub.rsa_public_key)); + GNUNET_JSON_from_rsa_public_key ( + pos->denom_pub.rsa_public_key)); json_object_set_new (obj, "ev_sig", - GNUNET_JSON_from_rsa_signature (pos->ev_sig.rsa_signature)); + GNUNET_JSON_from_rsa_signature ( + pos->ev_sig.rsa_signature)); json_object_set_new (obj, "link_sig", GNUNET_JSON_from_data_auto (&pos->orig_coin_link_sig)); @@ -113,7 +115,7 @@ handle_link_data (void *cls, root)) goto fail; return; - fail: + fail: ctx->ec = TALER_EC_JSON_ALLOCATION_FAILURE; json_decref (ctx->mlist); ctx->mlist = NULL; @@ -140,9 +142,9 @@ handle_link_data (void *cls, */ static enum GNUNET_DB_QueryStatus refresh_link_transaction (void *cls, - struct MHD_Connection *connection, - struct TALER_EXCHANGEDB_Session *session, - int *mhd_ret) + struct MHD_Connection *connection, + struct TALER_EXCHANGEDB_Session *session, + int *mhd_ret) { struct HTD_Context *ctx = cls; enum GNUNET_DB_QueryStatus qs; @@ -162,8 +164,8 @@ refresh_link_transaction (void *cls, if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs) { *mhd_ret = TEH_RESPONSE_reply_arg_unknown (connection, - TALER_EC_REFRESH_LINK_COIN_UNKNOWN, - "coin_pub"); + TALER_EC_REFRESH_LINK_COIN_UNKNOWN, + "coin_pub"); return GNUNET_DB_STATUS_HARD_ERROR; } return qs; @@ -193,12 +195,13 @@ TEH_REFRESH_handler_refresh_link (struct TEH_RequestHandler *rh, struct HTD_Context ctx; memset (&ctx, - 0, - sizeof (ctx)); + 0, + sizeof (ctx)); res = TEH_PARSE_mhd_request_arg_data (connection, "coin_pub", &ctx.coin_pub, - sizeof (struct TALER_CoinSpendPublicKeyP)); + 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 8677d6270..702857b8c 100644 --- a/src/exchange/taler-exchange-httpd_refresh_melt.c +++ b/src/exchange/taler-exchange-httpd_refresh_melt.c @@ -48,9 +48,11 @@ */ static int reply_refresh_melt_insufficient_funds (struct MHD_Connection *connection, - const struct TALER_CoinSpendPublicKeyP *coin_pub, + const struct + TALER_CoinSpendPublicKeyP *coin_pub, struct TALER_Amount coin_value, - struct TALER_EXCHANGEDB_TransactionList *tl, + struct TALER_EXCHANGEDB_TransactionList * + tl, const struct TALER_Amount *requested, const struct TALER_Amount *residual) { @@ -59,14 +61,15 @@ reply_refresh_melt_insufficient_funds (struct MHD_Connection *connection, history = TEH_RESPONSE_compile_transaction_history (tl); if (NULL == history) return TEH_RESPONSE_reply_internal_db_error (connection, - TALER_EC_REFRESH_MELT_HISTORY_DB_ERROR_INSUFFICIENT_FUNDS); + TALER_EC_REFRESH_MELT_HISTORY_DB_ERROR_INSUFFICIENT_FUNDS); return TEH_RESPONSE_reply_json_pack (connection, MHD_HTTP_FORBIDDEN, "{s:s, s:I, s:o, s:o, s:o, s:o, s:o}", "error", "insufficient funds", "code", - (json_int_t) TALER_EC_REFRESH_MELT_INSUFFICIENT_FUNDS, + (json_int_t) + TALER_EC_REFRESH_MELT_INSUFFICIENT_FUNDS, "coin_pub", GNUNET_JSON_from_data_auto (coin_pub), "original_value", @@ -104,8 +107,8 @@ reply_refresh_melt_success (struct MHD_Connection *connection, body.noreveal_index = htonl (noreveal_index); if (GNUNET_OK != TEH_KS_sign (&body.purpose, - &pub, - &sig)) + &pub, + &sig)) { return TEH_RESPONSE_reply_internal_error (connection, TALER_EC_EXCHANGE_BAD_CONFIGURATION, @@ -118,7 +121,8 @@ reply_refresh_melt_success (struct MHD_Connection *connection, "{s:i, s:o, s:o}", "noreveal_index", (int) noreveal_index, "exchange_sig", sig_json, - "exchange_pub", GNUNET_JSON_from_data_auto (&pub)); + "exchange_pub", + GNUNET_JSON_from_data_auto (&pub)); } @@ -238,10 +242,12 @@ refresh_check_melt (struct MHD_Connection *connection, &spent, &rmc->refresh_session.amount_with_fee)); *mhd_ret = reply_refresh_melt_insufficient_funds (connection, - &rmc->refresh_session.coin.coin_pub, + &rmc->refresh_session.coin + .coin_pub, coin_value, tl, - &rmc->refresh_session.amount_with_fee, + &rmc->refresh_session. + amount_with_fee, &coin_residual); TEH_plugin->free_coin_transaction_list (TEH_plugin->cls, tl); @@ -365,8 +371,8 @@ handle_refresh_melt (struct MHD_Connection *connection, { GNUNET_break_op (0); return TEH_RESPONSE_reply_external_error (connection, - TALER_EC_REFRESH_MELT_FEES_EXCEED_CONTRIBUTION, - "melt amount smaller than melting fee"); + TALER_EC_REFRESH_MELT_FEES_EXCEED_CONTRIBUTION, + "melt amount smaller than melting fee"); } } @@ -374,19 +380,22 @@ handle_refresh_melt (struct MHD_Connection *connection, { struct TALER_RefreshMeltCoinAffirmationPS body; - body.purpose.size = htonl (sizeof (struct TALER_RefreshMeltCoinAffirmationPS)); + body.purpose.size = htonl (sizeof (struct + TALER_RefreshMeltCoinAffirmationPS)); body.purpose.purpose = htonl (TALER_SIGNATURE_WALLET_COIN_MELT); body.rc = rmc->refresh_session.rc; TALER_amount_hton (&body.amount_with_fee, - &rmc->refresh_session.amount_with_fee); + &rmc->refresh_session.amount_with_fee); body.melt_fee = rmc->dki->issue.properties.fee_refresh; body.coin_pub = rmc->refresh_session.coin.coin_pub; if (GNUNET_OK != GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_WALLET_COIN_MELT, &body.purpose, - &rmc->refresh_session.coin_sig.eddsa_signature, - &rmc->refresh_session.coin.coin_pub.eddsa_pub)) + &rmc->refresh_session.coin_sig. + eddsa_signature, + &rmc->refresh_session.coin.coin_pub. + eddsa_pub)) { GNUNET_break_op (0); return TEH_RESPONSE_reply_signature_invalid (connection, @@ -489,7 +498,8 @@ TEH_REFRESH_handler_refresh_melt (struct TEH_RequestHandler *rh, /* Baseline: check if deposits/refreshs are generally simply still allowed for this denomination */ rmc.dki = TEH_KS_denomination_key_lookup_by_hash (key_state, - &rmc.refresh_session.coin.denom_pub_hash, + &rmc.refresh_session.coin. + denom_pub_hash, TEH_KS_DKU_DEPOSIT); /* Consider case that denomination was revoked but this coin was already seen and thus refresh is OK. */ @@ -498,7 +508,8 @@ TEH_REFRESH_handler_refresh_melt (struct TEH_RequestHandler *rh, struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *dki; dki = TEH_KS_denomination_key_lookup_by_hash (key_state, - &rmc.refresh_session.coin.denom_pub_hash, + &rmc.refresh_session.coin. + denom_pub_hash, TEH_KS_DKU_PAYBACK); if (NULL != dki) { @@ -533,7 +544,8 @@ TEH_REFRESH_handler_refresh_melt (struct TEH_RequestHandler *rh, struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *dki; dki = TEH_KS_denomination_key_lookup_by_hash (key_state, - &rmc.refresh_session.coin.denom_pub_hash, + &rmc.refresh_session.coin. + denom_pub_hash, TEH_KS_DKU_ZOMBIE); if (NULL != dki) { @@ -585,7 +597,7 @@ TEH_REFRESH_handler_refresh_melt (struct TEH_RequestHandler *rh, &rmc); - cleanup: + cleanup: if (NULL != key_state) { TEH_KS_release (key_state); @@ -593,7 +605,8 @@ TEH_REFRESH_handler_refresh_melt (struct TEH_RequestHandler *rh, } if (NULL != rmc.refresh_session.coin.denom_sig.rsa_signature) { - GNUNET_CRYPTO_rsa_signature_free (rmc.refresh_session.coin.denom_sig.rsa_signature); + GNUNET_CRYPTO_rsa_signature_free ( + rmc.refresh_session.coin.denom_sig.rsa_signature); rmc.refresh_session.coin.denom_sig.rsa_signature = NULL; } GNUNET_JSON_parse_free (spec); diff --git a/src/exchange/taler-exchange-httpd_refresh_reveal.c b/src/exchange/taler-exchange-httpd_refresh_reveal.c index 47287b155..a84e5dea7 100644 --- a/src/exchange/taler-exchange-httpd_refresh_reveal.c +++ b/src/exchange/taler-exchange-httpd_refresh_reveal.c @@ -54,8 +54,8 @@ */ static int reply_refresh_reveal_success (struct MHD_Connection *connection, - unsigned int num_newcoins, - const struct TALER_DenominationSignature *sigs) + unsigned int num_newcoins, + const struct TALER_DenominationSignature *sigs) { json_t *list; int ret; @@ -69,8 +69,9 @@ reply_refresh_reveal_success (struct MHD_Connection *connection, obj = json_object (); json_object_set_new (obj, - "ev_sig", - GNUNET_JSON_from_rsa_signature (sigs[newcoin_index].rsa_signature)); + "ev_sig", + GNUNET_JSON_from_rsa_signature ( + sigs[newcoin_index].rsa_signature)); GNUNET_assert (0 == json_array_append_new (list, obj)); @@ -102,14 +103,17 @@ reply_refresh_reveal_success (struct MHD_Connection *connection, */ static int reply_refresh_reveal_missmatch (struct MHD_Connection *connection, - const struct TALER_RefreshCommitmentP *rc) + const struct TALER_RefreshCommitmentP *rc) { return TEH_RESPONSE_reply_json_pack (connection, MHD_HTTP_CONFLICT, "{s:s, s:I, s:o}", "error", "commitment violation", - "code", (json_int_t) TALER_EC_REFRESH_REVEAL_COMMITMENT_VIOLATION, - "rc_expected", GNUNET_JSON_from_data_auto (rc)); + "code", + (json_int_t) + TALER_EC_REFRESH_REVEAL_COMMITMENT_VIOLATION, + "rc_expected", + GNUNET_JSON_from_data_auto (rc)); } @@ -205,14 +209,15 @@ check_exists_cb (void *cls, sizeof (struct TALER_TransferPublicKeyP))); GNUNET_break_op (0 == memcmp (tprivs, &rctx->transfer_privs, - sizeof (struct TALER_TransferPrivateKeyP) * num_tprivs)); + sizeof (struct TALER_TransferPrivateKeyP) + * num_tprivs)); /* We usually sign early (optimistic!), but in case we change that *and* we do find the operation in the database, we could use this: */ if (NULL == rctx->ev_sigs) { rctx->ev_sigs = GNUNET_new_array (num_newcoins, struct TALER_DenominationSignature); - for (unsigned int i=0;iev_sigs[i].rsa_signature = GNUNET_CRYPTO_rsa_signature_dup (rrcs[i].coin_sig.rsa_signature); } @@ -245,7 +250,8 @@ refresh_reveal_preflight (void *cls, &rctx->rc, &check_exists_cb, rctx); - switch (qs) { + switch (qs) + { case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: return qs; /* continue normal execution */ case GNUNET_DB_STATUS_SOFT_ERROR: @@ -253,7 +259,7 @@ refresh_reveal_preflight (void *cls, case GNUNET_DB_STATUS_HARD_ERROR: GNUNET_break (qs); *mhd_ret = TEH_RESPONSE_reply_internal_db_error (connection, - TALER_EC_REFRESH_REVEAL_DB_FETCH_REVEAL_ERROR); + TALER_EC_REFRESH_REVEAL_DB_FETCH_REVEAL_ERROR); rctx->preflight_ok = GNUNET_SYSERR; return GNUNET_DB_STATUS_HARD_ERROR; case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT: @@ -275,7 +281,8 @@ refresh_reveal_preflight (void *cls, static void free_refresh_melt (struct TALER_EXCHANGEDB_RefreshMelt *refresh_melt) { - GNUNET_CRYPTO_rsa_signature_free (refresh_melt->session.coin.denom_sig.rsa_signature); + GNUNET_CRYPTO_rsa_signature_free ( + refresh_melt->session.coin.denom_sig.rsa_signature); } @@ -299,9 +306,9 @@ free_refresh_melt (struct TALER_EXCHANGEDB_RefreshMelt *refresh_melt) */ static enum GNUNET_DB_QueryStatus refresh_reveal_transaction (void *cls, - struct MHD_Connection *connection, - struct TALER_EXCHANGEDB_Session *session, - int *mhd_ret) + struct MHD_Connection *connection, + struct TALER_EXCHANGEDB_Session *session, + int *mhd_ret) { struct RevealContext *rctx = cls; struct TALER_EXCHANGEDB_RefreshMelt refresh_melt; @@ -316,8 +323,8 @@ refresh_reveal_transaction (void *cls, if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs) { *mhd_ret = TEH_RESPONSE_reply_arg_invalid (connection, - TALER_EC_REFRESH_REVEAL_SESSION_UNKNOWN, - "rc"); + TALER_EC_REFRESH_REVEAL_SESSION_UNKNOWN, + "rc"); return GNUNET_DB_STATUS_HARD_ERROR; } if (GNUNET_DB_STATUS_SOFT_ERROR == qs) @@ -327,7 +334,7 @@ refresh_reveal_transaction (void *cls, { GNUNET_break (0); *mhd_ret = TEH_RESPONSE_reply_internal_db_error (connection, - TALER_EC_REFRESH_REVEAL_DB_FETCH_SESSION_ERROR); + TALER_EC_REFRESH_REVEAL_DB_FETCH_SESSION_ERROR); if (refresh_melt.session.noreveal_index >= TALER_CNC_KAPPA) free_refresh_melt (&refresh_melt); return GNUNET_DB_STATUS_HARD_ERROR; @@ -343,7 +350,7 @@ refresh_reveal_transaction (void *cls, unsigned int off; off = 0; /* did we pass session.noreveal_index yet? */ - for (unsigned int i=0;itransfer_privs[i - off]; + struct TALER_TransferPrivateKeyP *tpriv = &rctx->transfer_privs[i + - off]; struct TALER_TransferSecretP ts; GNUNET_CRYPTO_ecdhe_key_get_public (&tpriv->ecdhe_priv, @@ -367,7 +375,7 @@ refresh_reveal_transaction (void *cls, &ts); rce->new_coins = GNUNET_new_array (rctx->num_fresh_coins, struct TALER_RefreshCoinData); - for (unsigned int j=0;jnum_fresh_coins;j++) + for (unsigned int j = 0; jnum_fresh_coins; j++) { struct TALER_RefreshCoinData *rcd = &rce->new_coins[j]; struct TALER_PlanchetSecretsP ps; @@ -394,13 +402,13 @@ refresh_reveal_transaction (void *cls, &refresh_melt.session.amount_with_fee); /* Free resources allocated above */ - for (unsigned int i=0;inum_fresh_coins;j++) + for (unsigned int j = 0; jnum_fresh_coins; j++) { struct TALER_RefreshCoinData *rcd = &rce->new_coins[j]; @@ -426,7 +434,7 @@ refresh_reveal_transaction (void *cls, struct TALER_Amount refresh_cost; refresh_cost = refresh_melt.melt_fee; - for (unsigned int i=0;inum_fresh_coins;i++) + for (unsigned int i = 0; inum_fresh_coins; i++) { struct TALER_Amount fee_withdraw; struct TALER_Amount value; @@ -492,7 +500,7 @@ refresh_reveal_persist (void *cls, { struct TALER_EXCHANGEDB_RefreshRevealedCoin rrcs[rctx->num_fresh_coins]; - for (unsigned int i=0;inum_fresh_coins;i++) + for (unsigned int i = 0; inum_fresh_coins; i++) { struct TALER_EXCHANGEDB_RefreshRevealedCoin *rrc = &rrcs[i]; @@ -564,7 +572,7 @@ handle_refresh_reveal_json (struct MHD_Connection *connection, { GNUNET_break_op (0); return TEH_RESPONSE_reply_arg_invalid (connection, - TALER_EC_REFRESH_REVEAL_NEW_DENOMS_ARRAY_SIZE_MISSMATCH, + TALER_EC_REFRESH_REVEAL_NEW_DENOMS_ARRAY_SIZE_MISSMATCH, "new_denoms/coin_evs"); } if (json_array_size (new_denoms_h_json) != @@ -577,7 +585,7 @@ handle_refresh_reveal_json (struct MHD_Connection *connection, } /* Parse transfer private keys array */ - for (unsigned int i=0;itransfer_privs[i]), @@ -596,7 +604,8 @@ handle_refresh_reveal_json (struct MHD_Connection *connection, /* Resolve denomination hashes */ { - const struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *dkis[num_fresh_coins]; + const struct + TALER_EXCHANGEDB_DenominationKeyIssueInformation *dkis[num_fresh_coins]; struct GNUNET_HashCode dki_h[num_fresh_coins]; struct TALER_RefreshCoinData rcds[num_fresh_coins]; struct TALER_CoinSpendSignatureP link_sigs[num_fresh_coins]; @@ -614,7 +623,7 @@ handle_refresh_reveal_json (struct MHD_Connection *connection, } /* Parse denomination key hashes */ - for (unsigned int i=0;iev_sigs = GNUNET_new_array (rctx->num_fresh_coins, struct TALER_DenominationSignature); - for (unsigned int i=0;inum_fresh_coins;i++) + for (unsigned int i = 0; inum_fresh_coins; i++) { rctx->ev_sigs[i].rsa_signature - = GNUNET_CRYPTO_rsa_sign_blinded (rctx->dkis[i]->denom_priv.rsa_private_key, - rctx->rcds[i].coin_ev, - rctx->rcds[i].coin_ev_size); + = GNUNET_CRYPTO_rsa_sign_blinded ( + rctx->dkis[i]->denom_priv.rsa_private_key, + rctx->rcds[i].coin_ev, + rctx->rcds[i].coin_ev_size); if (NULL == rctx->ev_sigs[i].rsa_signature) { GNUNET_break (0); @@ -772,7 +783,7 @@ handle_refresh_reveal_json (struct MHD_Connection *connection, the pre-check might be satisfied by a concurrent transaction voiding our final commit due to uniqueness violation; naturally, on hard errors we exit immediately */ - for (unsigned int retries=0;retries < MAX_REVEAL_RETRIES;retries++) + for (unsigned int retries = 0; retries < MAX_REVEAL_RETRIES; retries++) { /* do transactional work */ rctx->preflight_ok = GNUNET_NO; @@ -825,17 +836,17 @@ handle_refresh_reveal_json (struct MHD_Connection *connection, } /* end for (retries...) */ GNUNET_break (MHD_NO != res); - cleanup: + cleanup: GNUNET_break (MHD_NO != res); /* free resources */ if (NULL != rctx->ev_sigs) { - for (unsigned int i=0;iev_sigs[i].rsa_signature) GNUNET_CRYPTO_rsa_signature_free (rctx->ev_sigs[i].rsa_signature); GNUNET_free (rctx->ev_sigs); } - for (unsigned int i=0;irefund_fee); if (GNUNET_OK != TEH_KS_sign (&rc.purpose, - &pub, - &sig)) + &pub, + &sig)) { return TEH_RESPONSE_reply_internal_error (connection, TALER_EC_EXCHANGE_BAD_CONFIGURATION, @@ -75,7 +75,8 @@ reply_refund_success (struct MHD_Connection *connection, "{s:s, s:o, s:o}", "status", "REFUND_OK", "sig", GNUNET_JSON_from_data_auto (&sig), - "pub", GNUNET_JSON_from_data_auto (&pub)); + "pub", GNUNET_JSON_from_data_auto ( + &pub)); } @@ -90,14 +91,14 @@ reply_refund_success (struct MHD_Connection *connection, */ static int reply_refund_failure (struct MHD_Connection *connection, - unsigned int response_code, - enum TALER_ErrorCode ec) + unsigned int response_code, + enum TALER_ErrorCode ec) { return TEH_RESPONSE_reply_json_pack (connection, response_code, "{s:s, s:I}", "status", "refund failure", - "code", (json_int_t) ec); + "code", (json_int_t) ec); } @@ -111,14 +112,17 @@ reply_refund_failure (struct MHD_Connection *connection, */ static int reply_refund_conflict (struct MHD_Connection *connection, - const struct TALER_EXCHANGEDB_TransactionList *tl) + const struct TALER_EXCHANGEDB_TransactionList *tl) { return TEH_RESPONSE_reply_json_pack (connection, MHD_HTTP_CONFLICT, "{s:s, s:I, s:o}", "status", "conflicting refund", - "code", (json_int_t) TALER_EC_REFUND_CONFLICT, - "history", TEH_RESPONSE_compile_transaction_history (tl)); + "code", + (json_int_t) TALER_EC_REFUND_CONFLICT, + "history", + TEH_RESPONSE_compile_transaction_history ( + tl)); } @@ -142,9 +146,9 @@ reply_refund_conflict (struct MHD_Connection *connection, */ static enum GNUNET_DB_QueryStatus refund_transaction (void *cls, - struct MHD_Connection *connection, - struct TALER_EXCHANGEDB_Session *session, - int *mhd_ret) + struct MHD_Connection *connection, + struct TALER_EXCHANGEDB_Session *session, + int *mhd_ret) { const struct TALER_EXCHANGEDB_Refund *refund = cls; struct TALER_EXCHANGEDB_TransactionList *tl; @@ -170,8 +174,8 @@ refund_transaction (void *cls, { if (GNUNET_DB_STATUS_HARD_ERROR == qs) *mhd_ret = reply_refund_failure (connection, - MHD_HTTP_NOT_FOUND, - TALER_EC_REFUND_COIN_NOT_FOUND); + MHD_HTTP_NOT_FOUND, + TALER_EC_REFUND_COIN_NOT_FOUND); return qs; } deposit_found = GNUNET_NO; @@ -254,14 +258,14 @@ refund_transaction (void *cls, TEH_plugin->free_coin_transaction_list (TEH_plugin->cls, tl); *mhd_ret = TEH_RESPONSE_reply_transaction_unknown (connection, - TALER_EC_REFUND_DEPOSIT_NOT_FOUND); + TALER_EC_REFUND_DEPOSIT_NOT_FOUND); return GNUNET_DB_STATUS_HARD_ERROR; } /* handle if conflicting refund found */ if (GNUNET_SYSERR == refund_found) { *mhd_ret = reply_refund_conflict (connection, - tl); + tl); TEH_plugin->free_coin_transaction_list (TEH_plugin->cls, tl); return GNUNET_DB_STATUS_HARD_ERROR; @@ -271,7 +275,7 @@ refund_transaction (void *cls, { /* /refund already done, simply re-transmit confirmation */ *mhd_ret = reply_refund_success (connection, - ref); + ref); TEH_plugin->free_coin_transaction_list (TEH_plugin->cls, tl); return GNUNET_DB_STATUS_HARD_ERROR; @@ -287,15 +291,15 @@ refund_transaction (void *cls, { GNUNET_break_op (0); /* currency missmatch */ *mhd_ret = reply_refund_failure (connection, - MHD_HTTP_PRECONDITION_FAILED, - TALER_EC_REFUND_CURRENCY_MISSMATCH); + MHD_HTTP_PRECONDITION_FAILED, + TALER_EC_REFUND_CURRENCY_MISSMATCH); return GNUNET_DB_STATUS_HARD_ERROR; } /* check if we already send the money for the /deposit */ qs = TEH_plugin->test_deposit_done (TEH_plugin->cls, - session, - dep); + session, + dep); if (GNUNET_DB_STATUS_HARD_ERROR == qs) { /* Internal error, we first had the deposit in the history, @@ -304,8 +308,8 @@ refund_transaction (void *cls, TEH_plugin->free_coin_transaction_list (TEH_plugin->cls, tl); *mhd_ret = TEH_RESPONSE_reply_internal_error (connection, - TALER_EC_REFUND_DB_INCONSISTENT, - "database inconsistent"); + TALER_EC_REFUND_DB_INCONSISTENT, + "database inconsistent"); return qs; } if (GNUNET_DB_STATUS_SOFT_ERROR == qs) @@ -317,8 +321,8 @@ refund_transaction (void *cls, TEH_plugin->free_coin_transaction_list (TEH_plugin->cls, tl); *mhd_ret = reply_refund_failure (connection, - MHD_HTTP_GONE, - TALER_EC_REFUND_MERCHANT_ALREADY_PAID); + MHD_HTTP_GONE, + TALER_EC_REFUND_MERCHANT_ALREADY_PAID); return GNUNET_DB_STATUS_HARD_ERROR; } @@ -330,8 +334,8 @@ refund_transaction (void *cls, TEH_plugin->free_coin_transaction_list (TEH_plugin->cls, tl); *mhd_ret = reply_refund_failure (connection, - MHD_HTTP_PRECONDITION_FAILED, - TALER_EC_REFUND_INSUFFICIENT_FUNDS); + MHD_HTTP_PRECONDITION_FAILED, + TALER_EC_REFUND_INSUFFICIENT_FUNDS); return GNUNET_DB_STATUS_HARD_ERROR; } @@ -360,8 +364,8 @@ refund_transaction (void *cls, TEH_plugin->free_coin_transaction_list (TEH_plugin->cls, tl); *mhd_ret = TEH_RESPONSE_reply_internal_error (connection, - TALER_EC_REFUND_DENOMINATION_KEY_NOT_FOUND, - "denomination key not found"); + TALER_EC_REFUND_DENOMINATION_KEY_NOT_FOUND, + "denomination key not found"); return GNUNET_DB_STATUS_HARD_ERROR; } TALER_amount_ntoh (&expect_fee, @@ -375,8 +379,8 @@ refund_transaction (void *cls, TEH_plugin->free_coin_transaction_list (TEH_plugin->cls, tl); *mhd_ret = TEH_RESPONSE_reply_arg_invalid (connection, - TALER_EC_REFUND_FEE_TOO_LOW, - "refund_fee"); + TALER_EC_REFUND_FEE_TOO_LOW, + "refund_fee"); return GNUNET_DB_STATUS_HARD_ERROR; } if (1 == fee_cmp) @@ -389,13 +393,13 @@ refund_transaction (void *cls, /* Finally, store new refund data */ qs = TEH_plugin->insert_refund (TEH_plugin->cls, - session, - refund); + session, + refund); if (GNUNET_DB_STATUS_HARD_ERROR == qs) { TALER_LOG_WARNING ("Failed to store /refund information in database\n"); *mhd_ret = TEH_RESPONSE_reply_internal_db_error (connection, - TALER_EC_REFUND_STORE_DB_ERROR); + TALER_EC_REFUND_STORE_DB_ERROR); return qs; } /* Success or soft failure */ @@ -415,7 +419,7 @@ refund_transaction (void *cls, */ static int verify_and_execute_refund (struct MHD_Connection *connection, - const struct TALER_EXCHANGEDB_Refund *refund) + const struct TALER_EXCHANGEDB_Refund *refund) { struct TALER_RefundRequestPS rr; int mhd_ret; @@ -436,7 +440,7 @@ verify_and_execute_refund (struct MHD_Connection *connection, { GNUNET_break_op (0); return TEH_RESPONSE_reply_arg_invalid (connection, - TALER_EC_REFUND_FEE_CURRENCY_MISSMATCH, + TALER_EC_REFUND_FEE_CURRENCY_MISSMATCH, "refund_fee"); } if (-1 == TALER_amount_cmp (&refund->refund_amount, @@ -444,8 +448,8 @@ verify_and_execute_refund (struct MHD_Connection *connection, { GNUNET_break_op (0); return TEH_RESPONSE_reply_arg_invalid (connection, - TALER_EC_REFUND_FEE_ABOVE_AMOUNT, - "refund_amount"); + TALER_EC_REFUND_FEE_ABOVE_AMOUNT, + "refund_amount"); } if (GNUNET_OK != GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_MERCHANT_REFUND, @@ -455,18 +459,18 @@ verify_and_execute_refund (struct MHD_Connection *connection, { TALER_LOG_WARNING ("Invalid signature on /refund request\n"); return TEH_RESPONSE_reply_signature_invalid (connection, - TALER_EC_REFUND_MERCHANT_SIGNATURE_INVALID, + TALER_EC_REFUND_MERCHANT_SIGNATURE_INVALID, "merchant_sig"); } if (GNUNET_OK != TEH_DB_run_transaction (connection, "run refund", - &mhd_ret, - &refund_transaction, - (void *) refund)) + &mhd_ret, + &refund_transaction, + (void *) refund)) return mhd_ret; return reply_refund_success (connection, - refund); + refund); } @@ -486,10 +490,10 @@ verify_and_execute_refund (struct MHD_Connection *connection, */ int TEH_REFUND_handler_refund (struct TEH_RequestHandler *rh, - struct MHD_Connection *connection, - void **connection_cls, - const char *upload_data, - size_t *upload_data_size) + struct MHD_Connection *connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size) { json_t *json; int res; @@ -523,7 +527,7 @@ TEH_REFUND_handler_refund (struct TEH_RequestHandler *rh, if (GNUNET_NO == res) return MHD_YES; /* failure */ res = verify_and_execute_refund (connection, - &refund); + &refund); GNUNET_JSON_parse_free (spec); return res; } diff --git a/src/exchange/taler-exchange-httpd_refund.h b/src/exchange/taler-exchange-httpd_refund.h index 1fa52b148..ce5aa351b 100644 --- a/src/exchange/taler-exchange-httpd_refund.h +++ b/src/exchange/taler-exchange-httpd_refund.h @@ -44,9 +44,9 @@ */ int TEH_REFUND_handler_refund (struct TEH_RequestHandler *rh, - struct MHD_Connection *connection, - void **connection_cls, - const char *upload_data, - size_t *upload_data_size); + struct MHD_Connection *connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size); #endif diff --git a/src/exchange/taler-exchange-httpd_reserve_status.c b/src/exchange/taler-exchange-httpd_reserve_status.c index 6ff73de75..a3f4dac9d 100644 --- a/src/exchange/taler-exchange-httpd_reserve_status.c +++ b/src/exchange/taler-exchange-httpd_reserve_status.c @@ -38,17 +38,17 @@ */ static int reply_reserve_status_success (struct MHD_Connection *connection, - const struct TALER_EXCHANGEDB_ReserveHistory *rh) + const struct TALER_EXCHANGEDB_ReserveHistory *rh) { json_t *json_balance; json_t *json_history; struct TALER_Amount balance; json_history = TEH_RESPONSE_compile_reserve_history (rh, - &balance); + &balance); if (NULL == json_history) return TEH_RESPONSE_reply_internal_error (connection, - TALER_EC_RESERVE_STATUS_DB_ERROR, + TALER_EC_RESERVE_STATUS_DB_ERROR, "balance calculation failure"); json_balance = TALER_JSON_from_amount (&balance); return TEH_RESPONSE_reply_json_pack (connection, @@ -96,16 +96,16 @@ struct ReserveStatusContext */ static enum GNUNET_DB_QueryStatus reserve_status_transaction (void *cls, - struct MHD_Connection *connection, - struct TALER_EXCHANGEDB_Session *session, - int *mhd_ret) + struct MHD_Connection *connection, + struct TALER_EXCHANGEDB_Session *session, + int *mhd_ret) { struct ReserveStatusContext *rsc = cls; return TEH_plugin->get_reserve_history (TEH_plugin->cls, - session, - &rsc->reserve_pub, - &rsc->rh); + session, + &rsc->reserve_pub, + &rsc->rh); } @@ -136,7 +136,8 @@ TEH_RESERVE_handler_reserve_status (struct TEH_RequestHandler *rh, res = TEH_PARSE_mhd_request_arg_data (connection, "reserve_pub", &rsc.reserve_pub, - sizeof (struct TALER_ReservePublicKeyP)); + sizeof (struct + TALER_ReservePublicKeyP)); if (GNUNET_SYSERR == res) return MHD_NO; /* internal error */ if (GNUNET_NO == res) @@ -145,9 +146,9 @@ TEH_RESERVE_handler_reserve_status (struct TEH_RequestHandler *rh, if (GNUNET_OK != TEH_DB_run_transaction (connection, "get reserve status", - &mhd_ret, - &reserve_status_transaction, - &rsc)) + &mhd_ret, + &reserve_status_transaction, + &rsc)) return mhd_ret; /* generate proper response */ @@ -157,9 +158,11 @@ TEH_RESERVE_handler_reserve_status (struct TEH_RequestHandler *rh, "{s:s, s:s, s:I}", "error", "Reserve not found", "parameter", "withdraw_pub", - "code", (json_int_t) TALER_EC_RESERVE_STATUS_UNKNOWN); + "code", + (json_int_t) + TALER_EC_RESERVE_STATUS_UNKNOWN); mhd_ret = reply_reserve_status_success (connection, - rsc.rh); + rsc.rh); TEH_plugin->free_reserve_history (TEH_plugin->cls, rsc.rh); return mhd_ret; diff --git a/src/exchange/taler-exchange-httpd_reserve_withdraw.c b/src/exchange/taler-exchange-httpd_reserve_withdraw.c index 65bca25e5..e5829d9dc 100644 --- a/src/exchange/taler-exchange-httpd_reserve_withdraw.c +++ b/src/exchange/taler-exchange-httpd_reserve_withdraw.c @@ -52,7 +52,8 @@ */ static int reply_reserve_withdraw_insufficient_funds (struct MHD_Connection *connection, - const struct TALER_EXCHANGEDB_ReserveHistory *rh) + const struct + TALER_EXCHANGEDB_ReserveHistory *rh) { json_t *json_balance; json_t *json_history; @@ -65,7 +66,7 @@ reply_reserve_withdraw_insufficient_funds (struct MHD_Connection *connection, * it fails "internally" to dump as string (= corrupted). */ || (0 == json_dumpb (json_history, NULL, 0, 0))) return TEH_RESPONSE_reply_internal_error (connection, - TALER_EC_WITHDRAW_HISTORY_DB_ERROR_INSUFFICIENT_FUNDS, + TALER_EC_WITHDRAW_HISTORY_DB_ERROR_INSUFFICIENT_FUNDS, "balance calculation failure"); json_balance = TALER_JSON_from_amount (&balance); @@ -73,7 +74,9 @@ reply_reserve_withdraw_insufficient_funds (struct MHD_Connection *connection, MHD_HTTP_FORBIDDEN, "{s:s, s:I, s:o, s:o}", "error", "Insufficient funds", - "code", (json_int_t) TALER_EC_WITHDRAW_INSUFFICIENT_FUNDS, + "code", + (json_int_t) + TALER_EC_WITHDRAW_INSUFFICIENT_FUNDS, "balance", json_balance, "history", json_history); } @@ -88,7 +91,9 @@ reply_reserve_withdraw_insufficient_funds (struct MHD_Connection *connection, */ static int reply_reserve_withdraw_success (struct MHD_Connection *connection, - const struct TALER_EXCHANGEDB_CollectableBlindcoin *collectable) + const struct + TALER_EXCHANGEDB_CollectableBlindcoin * + collectable) { json_t *sig_json; @@ -205,7 +210,7 @@ withdraw_transaction (void *cls, GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); if (GNUNET_DB_STATUS_HARD_ERROR == qs) *mhd_ret = TEH_RESPONSE_reply_internal_db_error (connection, - TALER_EC_WITHDRAW_DB_FETCH_ERROR); + TALER_EC_WITHDRAW_DB_FETCH_ERROR); wc->collectable.sig = denom_sig; return qs; } @@ -248,14 +253,14 @@ withdraw_transaction (void *cls, { if (GNUNET_DB_STATUS_HARD_ERROR == qs) *mhd_ret = TEH_RESPONSE_reply_internal_db_error (connection, - TALER_EC_WITHDRAW_DB_FETCH_ERROR); + TALER_EC_WITHDRAW_DB_FETCH_ERROR); return qs; } if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs) { *mhd_ret = TEH_RESPONSE_reply_arg_unknown (connection, - TALER_EC_WITHDRAW_RESERVE_UNKNOWN, - "reserve_pub"); + TALER_EC_WITHDRAW_RESERVE_UNKNOWN, + "reserve_pub"); return GNUNET_DB_STATUS_HARD_ERROR; } if (0 < TALER_amount_cmp (&wc->amount_required, @@ -293,7 +298,7 @@ withdraw_transaction (void *cls, } /* Balance is good, sign the coin! */ -#if !OPTIMISTIC_SIGN +#if ! OPTIMISTIC_SIGN if (NULL == wc->collectable.sig.rsa_signature) { wc->collectable.sig.rsa_signature @@ -326,7 +331,7 @@ withdraw_transaction (void *cls, GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); if (GNUNET_DB_STATUS_HARD_ERROR == qs) *mhd_ret = TEH_RESPONSE_reply_internal_db_error (connection, - TALER_EC_WITHDRAW_DB_STORE_ERROR); + TALER_EC_WITHDRAW_DB_STORE_ERROR); return qs; } return qs; @@ -407,7 +412,7 @@ TEH_RESERVE_handler_reserve_withdraw (struct TEH_RequestHandler *rh, GNUNET_JSON_parse_free (spec); TEH_KS_release (wc.key_state); return TEH_RESPONSE_reply_arg_unknown (connection, - TALER_EC_WITHDRAW_DENOMINATION_KEY_NOT_FOUND, + TALER_EC_WITHDRAW_DENOMINATION_KEY_NOT_FOUND, "denom_pub"); } GNUNET_assert (NULL != wc.dki->denom_priv.rsa_private_key); @@ -417,14 +422,14 @@ TEH_RESERVE_handler_reserve_withdraw (struct TEH_RequestHandler *rh, &wc.dki->issue.properties.fee_withdraw); if (GNUNET_OK != TALER_amount_add (&wc.amount_required, - &amount, - &fee_withdraw)) + &amount, + &fee_withdraw)) { GNUNET_JSON_parse_free (spec); TEH_KS_release (wc.key_state); return TEH_RESPONSE_reply_internal_error (connection, - TALER_EC_WITHDRAW_AMOUNT_FEE_OVERFLOW, - "amount overflow for value plus withdraw fee"); + TALER_EC_WITHDRAW_AMOUNT_FEE_OVERFLOW, + "amount overflow for value plus withdraw fee"); } TALER_amount_hton (&wc.wsrd.amount_with_fee, &wc.amount_required); @@ -446,11 +451,12 @@ TEH_RESERVE_handler_reserve_withdraw (struct TEH_RequestHandler *rh, &wc.signature.eddsa_signature, &wc.wsrd.reserve_pub.eddsa_pub)) { - TALER_LOG_WARNING ("Client supplied invalid signature for /reserve/withdraw request\n"); + TALER_LOG_WARNING ( + "Client supplied invalid signature for /reserve/withdraw request\n"); GNUNET_JSON_parse_free (spec); TEH_KS_release (wc.key_state); return TEH_RESPONSE_reply_signature_invalid (connection, - TALER_EC_WITHDRAW_RESERVE_SIGNATURE_INVALID, + TALER_EC_WITHDRAW_RESERVE_SIGNATURE_INVALID, "reserve_sig"); } @@ -474,9 +480,9 @@ TEH_RESERVE_handler_reserve_withdraw (struct TEH_RequestHandler *rh, if (GNUNET_OK != TEH_DB_run_transaction (connection, "run reserve withdraw", - &mhd_ret, - &withdraw_transaction, - &wc)) + &mhd_ret, + &withdraw_transaction, + &wc)) { TEH_KS_release (wc.key_state); /* Even if #withdraw_transaction() failed, it may have created a signature @@ -490,7 +496,7 @@ TEH_RESERVE_handler_reserve_withdraw (struct TEH_RequestHandler *rh, GNUNET_JSON_parse_free (spec); mhd_ret = reply_reserve_withdraw_success (connection, - &wc.collectable); + &wc.collectable); GNUNET_CRYPTO_rsa_signature_free (wc.collectable.sig.rsa_signature); return mhd_ret; } diff --git a/src/exchange/taler-exchange-httpd_responses.c b/src/exchange/taler-exchange-httpd_responses.c index f05e42604..1c2f92f0e 100644 --- a/src/exchange/taler-exchange-httpd_responses.c +++ b/src/exchange/taler-exchange-httpd_responses.c @@ -74,22 +74,22 @@ TEH_RESPONSE_can_compress (struct MHD_Connection *connection) const char *de; ae = MHD_lookup_connection_value (connection, - MHD_HEADER_KIND, - MHD_HTTP_HEADER_ACCEPT_ENCODING); + MHD_HEADER_KIND, + MHD_HTTP_HEADER_ACCEPT_ENCODING); if (NULL == ae) return MHD_NO; if (0 == strcmp (ae, "*")) return MHD_YES; de = strstr (ae, - "deflate"); + "deflate"); if (NULL == de) return MHD_NO; if ( ( (de == ae) || - (de[-1] == ',') || - (de[-1] == ' ') ) && + (de[-1] == ',') || + (de[-1] == ' ') ) && ( (de[strlen ("deflate")] == '\0') || - (de[strlen ("deflate")] == ',') || + (de[strlen ("deflate")] == ',') || (de[strlen ("deflate")] == ';') ) ) return MHD_YES; return MHD_NO; @@ -116,9 +116,9 @@ TEH_RESPONSE_body_compress (void **buf, if (NULL == cbuf) return MHD_NO; ret = compress (cbuf, - &cbuf_size, - (const Bytef *) *buf, - *buf_size); + &cbuf_size, + (const Bytef *) *buf, + *buf_size); if ( (Z_OK != ret) || (cbuf_size >= *buf_size) ) { @@ -153,7 +153,7 @@ TEH_RESPONSE_reply_json (struct MHD_Connection *connection, int comp; json_str = json_dumps (json, - JSON_INDENT(2)); + JSON_INDENT (2)); if (NULL == json_str) { /** @@ -172,7 +172,7 @@ TEH_RESPONSE_reply_json (struct MHD_Connection *connection, if (MHD_YES == TEH_RESPONSE_can_compress (connection)) comp = TEH_RESPONSE_body_compress (&json_str, - &json_len); + &json_len); resp = MHD_create_response_from_buffer (json_len, json_str, MHD_RESPMEM_MUST_FREE); @@ -460,7 +460,8 @@ TEH_RESPONSE_reply_invalid_json (struct MHD_Connection *connection) MHD_HTTP_BAD_REQUEST, "{s:s, s:I}", "error", "invalid json", - "code", (json_int_t) TALER_EC_JSON_INVALID); + "code", + (json_int_t) TALER_EC_JSON_INVALID); } @@ -471,7 +472,8 @@ TEH_RESPONSE_reply_invalid_json (struct MHD_Connection *connection) * @return json representation of the @a rh, NULL on error */ json_t * -TEH_RESPONSE_compile_transaction_history (const struct TALER_EXCHANGEDB_TransactionList *tl) +TEH_RESPONSE_compile_transaction_history (const struct + TALER_EXCHANGEDB_TransactionList *tl) { json_t *history; @@ -497,7 +499,8 @@ TEH_RESPONSE_compile_transaction_history (const struct TALER_EXCHANGEDB_Transact dr.h_contract_terms = deposit->h_contract_terms; dr.h_wire = deposit->h_wire; dr.timestamp = GNUNET_TIME_absolute_hton (deposit->timestamp); - dr.refund_deadline = GNUNET_TIME_absolute_hton (deposit->refund_deadline); + dr.refund_deadline = GNUNET_TIME_absolute_hton ( + deposit->refund_deadline); TALER_amount_hton (&dr.amount_with_fee, &deposit->amount_with_fee); TALER_amount_hton (&dr.deposit_fee, @@ -519,16 +522,32 @@ TEH_RESPONSE_compile_transaction_history (const struct TALER_EXCHANGEDB_Transact #endif if (0 != json_array_append_new (history, - json_pack ("{s:s, s:o, s:o, s:o, s:o, s:o, s:o, s:o, s:o}", - "type", "DEPOSIT", - "amount", TALER_JSON_from_amount (&deposit->amount_with_fee), - "deposit_fee", TALER_JSON_from_amount (&deposit->deposit_fee), - "timestamp", GNUNET_JSON_from_time_abs (deposit->timestamp), - "refund_deadline", GNUNET_JSON_from_time_abs (deposit->refund_deadline), - "merchant_pub", GNUNET_JSON_from_data_auto (&deposit->merchant_pub), - "h_contract_terms", GNUNET_JSON_from_data_auto (&deposit->h_contract_terms), - "h_wire", GNUNET_JSON_from_data_auto (&deposit->h_wire), - "coin_sig", GNUNET_JSON_from_data_auto (&deposit->csig)))) + json_pack ( + "{s:s, s:o, s:o, s:o, s:o, s:o, s:o, s:o, s:o}", + "type", "DEPOSIT", + "amount", TALER_JSON_from_amount ( + &deposit->amount_with_fee), + "deposit_fee", + TALER_JSON_from_amount ( + &deposit->deposit_fee), + "timestamp", + GNUNET_JSON_from_time_abs ( + deposit->timestamp), + "refund_deadline", + GNUNET_JSON_from_time_abs ( + deposit->refund_deadline), + "merchant_pub", + GNUNET_JSON_from_data_auto ( + &deposit->merchant_pub), + "h_contract_terms", + GNUNET_JSON_from_data_auto ( + &deposit->h_contract_terms), + "h_wire", + GNUNET_JSON_from_data_auto ( + &deposit->h_wire), + "coin_sig", + GNUNET_JSON_from_data_auto ( + &deposit->csig)))) { GNUNET_break (0); json_decref (history); @@ -542,7 +561,8 @@ TEH_RESPONSE_compile_transaction_history (const struct TALER_EXCHANGEDB_Transact const struct TALER_EXCHANGEDB_RefreshMelt *melt = pos->details.melt; ms.purpose.purpose = htonl (TALER_SIGNATURE_WALLET_COIN_MELT); - ms.purpose.size = htonl (sizeof (struct TALER_RefreshMeltCoinAffirmationPS)); + ms.purpose.size = htonl (sizeof (struct + TALER_RefreshMeltCoinAffirmationPS)); ms.rc = melt->session.rc; TALER_amount_hton (&ms.amount_with_fee, &melt->session.amount_with_fee); @@ -566,10 +586,16 @@ TEH_RESPONSE_compile_transaction_history (const struct TALER_EXCHANGEDB_Transact json_array_append_new (history, json_pack ("{s:s, s:o, s:o, s:o, s:o}", "type", "MELT", - "amount", TALER_JSON_from_amount (&melt->session.amount_with_fee), - "melt_fee", TALER_JSON_from_amount (&melt->melt_fee), - "rc", GNUNET_JSON_from_data_auto (&melt->session.rc), - "coin_sig", GNUNET_JSON_from_data_auto (&melt->session.coin_sig)))) + "amount", TALER_JSON_from_amount ( + &melt->session.amount_with_fee), + "melt_fee", + TALER_JSON_from_amount ( + &melt->melt_fee), + "rc", GNUNET_JSON_from_data_auto ( + &melt->session.rc), + "coin_sig", + GNUNET_JSON_from_data_auto ( + &melt->session.coin_sig)))) { GNUNET_break (0); json_decref (history); @@ -617,14 +643,25 @@ TEH_RESPONSE_compile_transaction_history (const struct TALER_EXCHANGEDB_Transact #endif if (0 != json_array_append_new (history, - json_pack ("{s:s, s:o, s:o, s:o, s:o, s:I, s:o}", - "type", "REFUND", - "amount", TALER_JSON_from_amount (&value), - "refund_fee", TALER_JSON_from_amount (&refund->refund_fee), - "h_contract_terms", GNUNET_JSON_from_data_auto (&refund->h_contract_terms), - "merchant_pub", GNUNET_JSON_from_data_auto (&refund->merchant_pub), - "rtransaction_id", (json_int_t) refund->rtransaction_id, - "merchant_sig", GNUNET_JSON_from_data_auto (&refund->merchant_sig)))) + json_pack ( + "{s:s, s:o, s:o, s:o, s:o, s:I, s:o}", + "type", "REFUND", + "amount", TALER_JSON_from_amount ( + &value), + "refund_fee", + TALER_JSON_from_amount ( + &refund->refund_fee), + "h_contract_terms", + GNUNET_JSON_from_data_auto ( + &refund->h_contract_terms), + "merchant_pub", + GNUNET_JSON_from_data_auto ( + &refund->merchant_pub), + "rtransaction_id", + (json_int_t) refund->rtransaction_id, + "merchant_sig", + GNUNET_JSON_from_data_auto ( + &refund->merchant_sig)))) { GNUNET_break (0); json_decref (history); @@ -634,12 +671,14 @@ TEH_RESPONSE_compile_transaction_history (const struct TALER_EXCHANGEDB_Transact break; case TALER_EXCHANGEDB_TT_OLD_COIN_PAYBACK: { - struct TALER_EXCHANGEDB_PaybackRefresh *pr = pos->details.old_coin_payback; + struct TALER_EXCHANGEDB_PaybackRefresh *pr = + pos->details.old_coin_payback; struct TALER_PaybackRefreshConfirmationPS pc; struct TALER_ExchangePublicKeyP epub; struct TALER_ExchangeSignatureP esig; - pc.purpose.purpose = htonl (TALER_SIGNATURE_EXCHANGE_CONFIRM_PAYBACK_REFRESH); + pc.purpose.purpose = htonl ( + TALER_SIGNATURE_EXCHANGE_CONFIRM_PAYBACK_REFRESH); pc.purpose.size = htonl (sizeof (pc)); pc.timestamp = GNUNET_TIME_absolute_hton (pr->timestamp); TALER_amount_hton (&pc.payback_amount, @@ -664,11 +703,20 @@ TEH_RESPONSE_compile_transaction_history (const struct TALER_EXCHANGEDB_Transact json_array_append_new (history, json_pack ("{s:s, s:o, s:o, s:o, s:o, s:o}", "type", "OLD-COIN-PAYBACK", - "amount", TALER_JSON_from_amount (&pr->value), - "exchange_sig", GNUNET_JSON_from_data_auto (&esig), - "exchange_pub", GNUNET_JSON_from_data_auto (&epub), - "coin_pub", GNUNET_JSON_from_data_auto (&pr->coin.coin_pub), - "timestamp", GNUNET_JSON_from_time_abs (pr->timestamp)))) + "amount", TALER_JSON_from_amount ( + &pr->value), + "exchange_sig", + GNUNET_JSON_from_data_auto ( + &esig), + "exchange_pub", + GNUNET_JSON_from_data_auto ( + &epub), + "coin_pub", + GNUNET_JSON_from_data_auto ( + &pr->coin.coin_pub), + "timestamp", + GNUNET_JSON_from_time_abs ( + pr->timestamp)))) { GNUNET_break (0); json_decref (history); @@ -703,11 +751,20 @@ TEH_RESPONSE_compile_transaction_history (const struct TALER_EXCHANGEDB_Transact json_array_append_new (history, json_pack ("{s:s, s:o, s:o, s:o, s:o, s:o}", "type", "PAYBACK", - "amount", TALER_JSON_from_amount (&payback->value), - "exchange_sig", GNUNET_JSON_from_data_auto (&esig), - "exchange_pub", GNUNET_JSON_from_data_auto (&epub), - "reserve_pub", GNUNET_JSON_from_data_auto (&payback->reserve_pub), - "timestamp", GNUNET_JSON_from_time_abs (payback->timestamp)))) + "amount", TALER_JSON_from_amount ( + &payback->value), + "exchange_sig", + GNUNET_JSON_from_data_auto ( + &esig), + "exchange_pub", + GNUNET_JSON_from_data_auto ( + &epub), + "reserve_pub", + GNUNET_JSON_from_data_auto ( + &payback->reserve_pub), + "timestamp", + GNUNET_JSON_from_time_abs ( + payback->timestamp)))) { GNUNET_break (0); json_decref (history); @@ -717,12 +774,14 @@ TEH_RESPONSE_compile_transaction_history (const struct TALER_EXCHANGEDB_Transact break; case TALER_EXCHANGEDB_TT_PAYBACK_REFRESH: { - struct TALER_EXCHANGEDB_PaybackRefresh *pr = pos->details.payback_refresh; + struct TALER_EXCHANGEDB_PaybackRefresh *pr = + pos->details.payback_refresh; struct TALER_PaybackRefreshConfirmationPS pc; struct TALER_ExchangePublicKeyP epub; struct TALER_ExchangeSignatureP esig; - pc.purpose.purpose = htonl (TALER_SIGNATURE_EXCHANGE_CONFIRM_PAYBACK_REFRESH); + pc.purpose.purpose = htonl ( + TALER_SIGNATURE_EXCHANGE_CONFIRM_PAYBACK_REFRESH); pc.purpose.size = htonl (sizeof (pc)); pc.timestamp = GNUNET_TIME_absolute_hton (pr->timestamp); TALER_amount_hton (&pc.payback_amount, @@ -747,11 +806,20 @@ TEH_RESPONSE_compile_transaction_history (const struct TALER_EXCHANGEDB_Transact json_array_append_new (history, json_pack ("{s:s, s:o, s:o, s:o, s:o, s:o}", "type", "PAYBACK-REFRESH", - "amount", TALER_JSON_from_amount (&pr->value), - "exchange_sig", GNUNET_JSON_from_data_auto (&esig), - "exchange_pub", GNUNET_JSON_from_data_auto (&epub), - "old_coin_pub", GNUNET_JSON_from_data_auto (&pr->old_coin_pub), - "timestamp", GNUNET_JSON_from_time_abs (pr->timestamp)))) + "amount", TALER_JSON_from_amount ( + &pr->value), + "exchange_sig", + GNUNET_JSON_from_data_auto ( + &esig), + "exchange_pub", + GNUNET_JSON_from_data_auto ( + &epub), + "old_coin_pub", + GNUNET_JSON_from_data_auto ( + &pr->old_coin_pub), + "timestamp", + GNUNET_JSON_from_time_abs ( + pr->timestamp)))) { GNUNET_break (0); json_decref (history); @@ -781,7 +849,8 @@ TEH_RESPONSE_compile_transaction_history (const struct TALER_EXCHANGEDB_Transact int TEH_RESPONSE_reply_coin_insufficient_funds (struct MHD_Connection *connection, enum TALER_ErrorCode ec, - const struct TALER_EXCHANGEDB_TransactionList *tl) + const struct + TALER_EXCHANGEDB_TransactionList *tl) { json_t *history; @@ -808,7 +877,8 @@ TEH_RESPONSE_reply_coin_insufficient_funds (struct MHD_Connection *connection, * @return json representation of the @a rh, NULL on error */ json_t * -TEH_RESPONSE_compile_reserve_history (const struct TALER_EXCHANGEDB_ReserveHistory *rh, +TEH_RESPONSE_compile_reserve_history (const struct + TALER_EXCHANGEDB_ReserveHistory *rh, struct TALER_Amount *balance) { struct TALER_Amount deposit_total; @@ -827,30 +897,38 @@ TEH_RESPONSE_compile_reserve_history (const struct TALER_EXCHANGEDB_ReserveHisto case TALER_EXCHANGEDB_RO_BANK_TO_EXCHANGE: if (0 == (1 & ret)) deposit_total = pos->details.bank->amount; - else - if (GNUNET_OK != - TALER_amount_add (&deposit_total, - &deposit_total, - &pos->details.bank->amount)) - { - GNUNET_break (0); - json_decref (json_history); - return NULL; - } + else if (GNUNET_OK != + TALER_amount_add (&deposit_total, + &deposit_total, + &pos->details.bank->amount)) + { + GNUNET_break (0); + json_decref (json_history); + return NULL; + } ret |= 1; if (0 != json_array_append_new (json_history, json_pack ("{s:s, s:o, s:s, s:o, s:o}", "type", "DEPOSIT", - "timestamp", GNUNET_JSON_from_time_abs (pos->details.bank->execution_date), - "sender_account_url", pos->details.bank->sender_account_details, - "wire_reference", GNUNET_JSON_from_data (pos->details.bank->wire_reference, - pos->details.bank->wire_reference_size), - "amount", TALER_JSON_from_amount (&pos->details.bank->amount)))) + "timestamp", + GNUNET_JSON_from_time_abs ( + pos->details.bank->execution_date), + "sender_account_url", + pos->details.bank-> + sender_account_details, + "wire_reference", + GNUNET_JSON_from_data ( + pos->details.bank->wire_reference, + pos + ->details. + bank->wire_reference_size), + "amount", TALER_JSON_from_amount ( + &pos->details.bank->amount)))) { GNUNET_break (0); - json_decref (json_history); - return NULL; + json_decref (json_history); + return NULL; } break; case TALER_EXCHANGEDB_RO_WITHDRAW_COIN: @@ -879,11 +957,24 @@ TEH_RESPONSE_compile_reserve_history (const struct TALER_EXCHANGEDB_ReserveHisto json_array_append_new (json_history, json_pack ("{s:s, s:o, s:o, s:o, s:o, s:o}", "type", "WITHDRAW", - "reserve_sig", GNUNET_JSON_from_data_auto (&pos->details.withdraw->reserve_sig), - "h_coin_envelope", GNUNET_JSON_from_data_auto (&pos->details.withdraw->h_coin_envelope), - "h_denom_pub", GNUNET_JSON_from_data_auto (&pos->details.withdraw->denom_pub_hash), - "withdraw_fee", TALER_JSON_from_amount (&pos->details.withdraw->withdraw_fee), - "amount", TALER_JSON_from_amount (&value)))) + "reserve_sig", + GNUNET_JSON_from_data_auto ( + &pos->details.withdraw-> + reserve_sig), + "h_coin_envelope", + GNUNET_JSON_from_data_auto ( + &pos->details.withdraw-> + h_coin_envelope), + "h_denom_pub", + GNUNET_JSON_from_data_auto ( + &pos->details.withdraw-> + denom_pub_hash), + "withdraw_fee", + TALER_JSON_from_amount ( + &pos->details.withdraw-> + withdraw_fee), + "amount", TALER_JSON_from_amount ( + &value)))) { GNUNET_break (0); json_decref (json_history); @@ -901,16 +992,15 @@ TEH_RESPONSE_compile_reserve_history (const struct TALER_EXCHANGEDB_ReserveHisto payback = pos->details.payback; if (0 == (1 & ret)) deposit_total = payback->value; - else - if (GNUNET_OK != - TALER_amount_add (&deposit_total, - &deposit_total, - &payback->value)) - { - GNUNET_break (0); - json_decref (json_history); - return NULL; - } + else if (GNUNET_OK != + TALER_amount_add (&deposit_total, + &deposit_total, + &payback->value)) + { + GNUNET_break (0); + json_decref (json_history); + return NULL; + } ret |= 1; pc.purpose.purpose = htonl (TALER_SIGNATURE_EXCHANGE_CONFIRM_PAYBACK); pc.purpose.size = htonl (sizeof (struct TALER_PaybackConfirmationPS)); @@ -933,11 +1023,18 @@ TEH_RESPONSE_compile_reserve_history (const struct TALER_EXCHANGEDB_ReserveHisto json_array_append_new (json_history, json_pack ("{s:s, s:o, s:o, s:o, s:o, s:o}", "type", "PAYBACK", - "exchange_pub", GNUNET_JSON_from_data_auto (&pub), - "exchange_sig", GNUNET_JSON_from_data_auto (&sig), - "timestamp", GNUNET_JSON_from_time_abs (payback->timestamp), - "amount", TALER_JSON_from_amount (&payback->value), - "coin_pub", GNUNET_JSON_from_data_auto (&payback->coin.coin_pub)))) + "exchange_pub", + GNUNET_JSON_from_data_auto (&pub), + "exchange_sig", + GNUNET_JSON_from_data_auto (&sig), + "timestamp", + GNUNET_JSON_from_time_abs ( + payback->timestamp), + "amount", TALER_JSON_from_amount ( + &payback->value), + "coin_pub", + GNUNET_JSON_from_data_auto ( + &payback->coin.coin_pub)))) { GNUNET_break (0); json_decref (json_history); @@ -971,15 +1068,19 @@ TEH_RESPONSE_compile_reserve_history (const struct TALER_EXCHANGEDB_ReserveHisto } ret |= 2; rcc.purpose.purpose = htonl (TALER_SIGNATURE_EXCHANGE_RESERVE_CLOSED); - rcc.purpose.size = htonl (sizeof (struct TALER_ReserveCloseConfirmationPS)); - rcc.timestamp = GNUNET_TIME_absolute_hton (pos->details.closing->execution_date); + rcc.purpose.size = htonl (sizeof (struct + TALER_ReserveCloseConfirmationPS)); + rcc.timestamp = GNUNET_TIME_absolute_hton ( + pos->details.closing->execution_date); TALER_amount_hton (&rcc.closing_amount, &value); TALER_amount_hton (&rcc.closing_fee, &pos->details.closing->closing_fee); rcc.reserve_pub = pos->details.closing->reserve_pub; GNUNET_CRYPTO_hash (pos->details.closing->receiver_account_details, - strlen (pos->details.closing->receiver_account_details) + 1, + strlen ( + pos->details.closing->receiver_account_details) + + 1, &rcc.h_wire); rcc.wtid = pos->details.closing->wtid; if (GNUNET_OK != @@ -993,15 +1094,27 @@ TEH_RESPONSE_compile_reserve_history (const struct TALER_EXCHANGEDB_ReserveHisto } if (0 != json_array_append_new (json_history, - json_pack ("{s:s, s:s, s:o, s:o, s:o, s:o, s:o, s:o}", - "type", "CLOSING", - "receiver_account_details", pos->details.closing->receiver_account_details, - "wtid", GNUNET_JSON_from_data_auto (&pos->details.closing->wtid), - "exchange_pub", GNUNET_JSON_from_data_auto (&pub), - "exchange_sig", GNUNET_JSON_from_data_auto (&sig), - "timestamp", GNUNET_JSON_from_time_abs (pos->details.closing->execution_date), - "amount", TALER_JSON_from_amount (&value), - "closing_fee", TALER_JSON_from_amount (&pos->details.closing->closing_fee)))) + json_pack ( + "{s:s, s:s, s:o, s:o, s:o, s:o, s:o, s:o}", + "type", "CLOSING", + "receiver_account_details", + pos->details.closing-> + receiver_account_details, + "wtid", + GNUNET_JSON_from_data_auto ( + &pos->details.closing->wtid), + "exchange_pub", + GNUNET_JSON_from_data_auto (&pub), + "exchange_sig", + GNUNET_JSON_from_data_auto (&sig), + "timestamp", + GNUNET_JSON_from_time_abs ( + pos->details.closing->execution_date), + "amount", TALER_JSON_from_amount ( + &value), + "closing_fee", + TALER_JSON_from_amount ( + &pos->details.closing->closing_fee)))) { GNUNET_break (0); json_decref (json_history); diff --git a/src/exchange/taler-exchange-httpd_responses.h b/src/exchange/taler-exchange-httpd_responses.h index 9b1271569..177eaa43e 100644 --- a/src/exchange/taler-exchange-httpd_responses.h +++ b/src/exchange/taler-exchange-httpd_responses.h @@ -54,7 +54,7 @@ TEH_RESPONSE_add_global_headers (struct MHD_Response *response); */ int TEH_RESPONSE_body_compress (void **buf, - size_t *buf_size); + size_t *buf_size); /** @@ -108,7 +108,7 @@ TEH_RESPONSE_reply_json_pack (struct MHD_Connection *connection, */ int TEH_RESPONSE_reply_signature_invalid (struct MHD_Connection *connection, - enum TALER_ErrorCode ec, + enum TALER_ErrorCode ec, const char *param_name); @@ -122,7 +122,7 @@ TEH_RESPONSE_reply_signature_invalid (struct MHD_Connection *connection, */ int TEH_RESPONSE_reply_arg_invalid (struct MHD_Connection *connection, - enum TALER_ErrorCode ec, + enum TALER_ErrorCode ec, const char *param_name); @@ -138,7 +138,7 @@ TEH_RESPONSE_reply_arg_invalid (struct MHD_Connection *connection, */ int TEH_RESPONSE_reply_arg_unknown (struct MHD_Connection *connection, - enum TALER_ErrorCode ec, + enum TALER_ErrorCode ec, const char *param_name); @@ -239,8 +239,9 @@ TEH_RESPONSE_reply_invalid_json (struct MHD_Connection *connectionx); * @return json representation of the @a rh, NULL on error */ json_t * -TEH_RESPONSE_compile_reserve_history (const struct TALER_EXCHANGEDB_ReserveHistory *rh, - struct TALER_Amount *balance); +TEH_RESPONSE_compile_reserve_history (const struct + TALER_EXCHANGEDB_ReserveHistory *rh, + struct TALER_Amount *balance); /** @@ -257,7 +258,8 @@ TEH_RESPONSE_compile_reserve_history (const struct TALER_EXCHANGEDB_ReserveHisto int TEH_RESPONSE_reply_coin_insufficient_funds (struct MHD_Connection *connection, enum TALER_ErrorCode ec, - const struct TALER_EXCHANGEDB_TransactionList *tl); + const struct + TALER_EXCHANGEDB_TransactionList *tl); /** @@ -271,7 +273,7 @@ TEH_RESPONSE_reply_coin_insufficient_funds (struct MHD_Connection *connection, */ int TEH_RESPONSE_reply_transaction_unknown (struct MHD_Connection *connection, - enum TALER_ErrorCode ec); + enum TALER_ErrorCode ec); /** @@ -281,7 +283,8 @@ TEH_RESPONSE_reply_transaction_unknown (struct MHD_Connection *connection, * @return json representation of the @a rh */ json_t * -TEH_RESPONSE_compile_transaction_history (const struct TALER_EXCHANGEDB_TransactionList *tl); +TEH_RESPONSE_compile_transaction_history (const struct + TALER_EXCHANGEDB_TransactionList *tl); #endif diff --git a/src/exchange/taler-exchange-httpd_test.c b/src/exchange/taler-exchange-httpd_test.c index 73ce0e556..b55a98885 100644 --- a/src/exchange/taler-exchange-httpd_test.c +++ b/src/exchange/taler-exchange-httpd_test.c @@ -53,10 +53,10 @@ static struct GNUNET_CRYPTO_RsaPrivateKey *rsa_pk; */ int TEH_TEST_handler_test_base32 (struct TEH_RequestHandler *rh, - struct MHD_Connection *connection, - void **connection_cls, - const char *upload_data, - size_t *upload_data_size) + struct MHD_Connection *connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size) { json_t *json; int res; @@ -78,20 +78,20 @@ TEH_TEST_handler_test_base32 (struct TEH_RequestHandler *rh, if ( (GNUNET_NO == res) || (NULL == json) ) return MHD_YES; res = TEH_PARSE_json_data (connection, - json, - spec); + json, + spec); if (GNUNET_YES != res) return (GNUNET_NO == res) ? MHD_YES : MHD_NO; GNUNET_CRYPTO_hash (in_ptr, - in_ptr_size, - &hc); + in_ptr_size, + &hc); GNUNET_JSON_parse_free (spec); json_decref (json); return TEH_RESPONSE_reply_json_pack (connection, - MHD_HTTP_OK, - "{s:o}", - "output", - GNUNET_JSON_from_data_auto (&hc)); + MHD_HTTP_OK, + "{s:o}", + "output", + GNUNET_JSON_from_data_auto (&hc)); } @@ -114,10 +114,10 @@ TEH_TEST_handler_test_base32 (struct TEH_RequestHandler *rh, */ int TEH_TEST_handler_test_encrypt (struct TEH_RequestHandler *rh, - struct MHD_Connection *connection, - void **connection_cls, - const char *upload_data, - size_t *upload_data_size) + struct MHD_Connection *connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size) { json_t *json; int res; @@ -143,37 +143,39 @@ TEH_TEST_handler_test_encrypt (struct TEH_RequestHandler *rh, if ( (GNUNET_NO == res) || (NULL == json) ) return MHD_YES; res = TEH_PARSE_json_data (connection, - json, - spec); + json, + spec); json_decref (json); if (GNUNET_YES != res) return (GNUNET_NO == res) ? MHD_YES : MHD_NO; GNUNET_assert (GNUNET_YES == - GNUNET_CRYPTO_kdf (&skey, sizeof (struct GNUNET_CRYPTO_SymmetricSessionKey), - "skey", strlen ("skey"), - &key, sizeof (key), - NULL, 0)); + GNUNET_CRYPTO_kdf (&skey, sizeof (struct + GNUNET_CRYPTO_SymmetricSessionKey), + "skey", strlen ("skey"), + &key, sizeof (key), + NULL, 0)); GNUNET_assert (GNUNET_YES == - GNUNET_CRYPTO_kdf (&iv, sizeof (struct GNUNET_CRYPTO_SymmetricInitializationVector), - "iv", strlen ("iv"), - &key, sizeof (key), - NULL, 0)); + GNUNET_CRYPTO_kdf (&iv, sizeof (struct + GNUNET_CRYPTO_SymmetricInitializationVector), + "iv", strlen ("iv"), + &key, sizeof (key), + NULL, 0)); out = GNUNET_malloc (in_ptr_size); GNUNET_break (in_ptr_size == - GNUNET_CRYPTO_symmetric_encrypt (in_ptr, - in_ptr_size, - &skey, - &iv, - out)); + GNUNET_CRYPTO_symmetric_encrypt (in_ptr, + in_ptr_size, + &skey, + &iv, + out)); json = GNUNET_JSON_from_data (out, in_ptr_size); GNUNET_free (out); GNUNET_JSON_parse_free (spec); return TEH_RESPONSE_reply_json_pack (connection, - MHD_HTTP_OK, - "{s:o}", - "output", - json); + MHD_HTTP_OK, + "{s:o}", + "output", + json); } @@ -196,10 +198,10 @@ TEH_TEST_handler_test_encrypt (struct TEH_RequestHandler *rh, */ int TEH_TEST_handler_test_hkdf (struct TEH_RequestHandler *rh, - struct MHD_Connection *connection, - void **connection_cls, - const char *upload_data, - size_t *upload_data_size) + struct MHD_Connection *connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size) { json_t *json; int res; @@ -221,8 +223,8 @@ TEH_TEST_handler_test_hkdf (struct TEH_RequestHandler *rh, if ( (GNUNET_NO == res) || (NULL == json) ) return MHD_YES; res = TEH_PARSE_json_data (connection, - json, - spec); + json, + spec); json_decref (json); if (GNUNET_YES != res) return (GNUNET_NO == res) ? MHD_YES : MHD_NO; @@ -235,10 +237,10 @@ TEH_TEST_handler_test_hkdf (struct TEH_RequestHandler *rh, GNUNET_JSON_parse_free (spec); json = GNUNET_JSON_from_data_auto (&hc); return TEH_RESPONSE_reply_json_pack (connection, - MHD_HTTP_OK, - "{s:o}", - "output", - json); + MHD_HTTP_OK, + "{s:o}", + "output", + json); } @@ -258,10 +260,10 @@ TEH_TEST_handler_test_hkdf (struct TEH_RequestHandler *rh, */ int TEH_TEST_handler_test_ecdhe (struct TEH_RequestHandler *rh, - struct MHD_Connection *connection, - void **connection_cls, - const char *upload_data, - size_t *upload_data_size) + struct MHD_Connection *connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size) { json_t *json; int res; @@ -284,27 +286,27 @@ TEH_TEST_handler_test_ecdhe (struct TEH_RequestHandler *rh, if ( (GNUNET_NO == res) || (NULL == json) ) return MHD_YES; res = TEH_PARSE_json_data (connection, - json, - spec); + json, + spec); json_decref (json); if (GNUNET_YES != res) return (GNUNET_NO == res) ? MHD_YES : MHD_NO; if (GNUNET_OK != GNUNET_CRYPTO_ecc_ecdh (&priv, - &pub, - &hc)) + &pub, + &hc)) { GNUNET_JSON_parse_free (spec); return TEH_RESPONSE_reply_internal_error (connection, - TALER_EC_TEST_ECDH_ERROR, - "Failed to perform ECDH"); + TALER_EC_TEST_ECDH_ERROR, + "Failed to perform ECDH"); } GNUNET_JSON_parse_free (spec); return TEH_RESPONSE_reply_json_pack (connection, - MHD_HTTP_OK, - "{s:o}", - "ecdh_hash", - GNUNET_JSON_from_data_auto (&hc)); + MHD_HTTP_OK, + "{s:o}", + "ecdh_hash", + GNUNET_JSON_from_data_auto (&hc)); } @@ -325,10 +327,10 @@ TEH_TEST_handler_test_ecdhe (struct TEH_RequestHandler *rh, */ int TEH_TEST_handler_test_eddsa (struct TEH_RequestHandler *rh, - struct MHD_Connection *connection, - void **connection_cls, - const char *upload_data, - size_t *upload_data_size) + struct MHD_Connection *connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size) { json_t *json; int res; @@ -352,8 +354,8 @@ TEH_TEST_handler_test_eddsa (struct TEH_RequestHandler *rh, if ( (GNUNET_NO == res) || (NULL == json) ) return MHD_YES; res = TEH_PARSE_json_data (connection, - json, - spec); + json, + spec); json_decref (json); if (GNUNET_YES != res) return (GNUNET_NO == res) ? MHD_YES : MHD_NO; @@ -361,38 +363,38 @@ TEH_TEST_handler_test_eddsa (struct TEH_RequestHandler *rh, purpose.purpose = htonl (TALER_SIGNATURE_CLIENT_TEST_EDDSA); if (GNUNET_OK != GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_CLIENT_TEST_EDDSA, - &purpose, - &sig, - &pub)) + &purpose, + &sig, + &pub)) { GNUNET_JSON_parse_free (spec); return TEH_RESPONSE_reply_signature_invalid (connection, - TALER_EC_TEST_EDDSA_INVALID, - "eddsa_sig"); + TALER_EC_TEST_EDDSA_INVALID, + "eddsa_sig"); } GNUNET_JSON_parse_free (spec); pk = GNUNET_CRYPTO_eddsa_key_create (); purpose.purpose = htonl (TALER_SIGNATURE_EXCHANGE_TEST_EDDSA); if (GNUNET_OK != GNUNET_CRYPTO_eddsa_sign (pk, - &purpose, - &sig)) + &purpose, + &sig)) { GNUNET_free (pk); return TEH_RESPONSE_reply_internal_error (connection, - TALER_EC_TEST_EDDSA_ERROR, - "Failed to EdDSA-sign"); + TALER_EC_TEST_EDDSA_ERROR, + "Failed to EdDSA-sign"); } GNUNET_CRYPTO_eddsa_key_get_public (pk, - &pub); + &pub); GNUNET_free (pk); return TEH_RESPONSE_reply_json_pack (connection, - MHD_HTTP_OK, - "{s:o, s:o}", - "eddsa_pub", - GNUNET_JSON_from_data_auto (&pub), - "eddsa_sig", - GNUNET_JSON_from_data_auto (&sig)); + MHD_HTTP_OK, + "{s:o, s:o}", + "eddsa_pub", + GNUNET_JSON_from_data_auto (&pub), + "eddsa_sig", + GNUNET_JSON_from_data_auto (&sig)); } @@ -423,22 +425,22 @@ TEH_TEST_handler_test_rsa_get (struct TEH_RequestHandler *rh, { GNUNET_break (0); return TEH_RESPONSE_reply_internal_error (connection, - TALER_EC_TEST_RSA_GEN_ERROR, - "Failed to create RSA key"); + TALER_EC_TEST_RSA_GEN_ERROR, + "Failed to create RSA key"); } pub = GNUNET_CRYPTO_rsa_private_key_get_public (rsa_pk); if (NULL == pub) { GNUNET_break (0); return TEH_RESPONSE_reply_internal_error (connection, - TALER_EC_TEST_RSA_PUB_ERROR, - "Failed to get public RSA key"); + TALER_EC_TEST_RSA_PUB_ERROR, + "Failed to get public RSA key"); } res = TEH_RESPONSE_reply_json_pack (connection, - MHD_HTTP_OK, - "{s:o}", - "rsa_pub", - GNUNET_JSON_from_rsa_public_key (pub)); + MHD_HTTP_OK, + "{s:o}", + "rsa_pub", + GNUNET_JSON_from_rsa_public_key (pub)); GNUNET_CRYPTO_rsa_public_key_free (pub); return res; } @@ -483,8 +485,8 @@ TEH_TEST_handler_test_rsa_sign (struct TEH_RequestHandler *rh, if ( (GNUNET_NO == res) || (NULL == json) ) return MHD_YES; res = TEH_PARSE_json_data (connection, - json, - spec); + json, + spec); json_decref (json); if (GNUNET_YES != res) return (GNUNET_NO == res) ? MHD_YES : MHD_NO; @@ -495,26 +497,26 @@ TEH_TEST_handler_test_rsa_sign (struct TEH_RequestHandler *rh, GNUNET_break (0); GNUNET_JSON_parse_free (spec); return TEH_RESPONSE_reply_internal_error (connection, - TALER_EC_TEST_RSA_GEN_ERROR, - "Failed to create RSA key"); + TALER_EC_TEST_RSA_GEN_ERROR, + "Failed to create RSA key"); } sig = GNUNET_CRYPTO_rsa_sign_blinded (rsa_pk, - in_ptr, - in_ptr_size); + in_ptr, + in_ptr_size); if (NULL == sig) { GNUNET_break (0); GNUNET_JSON_parse_free (spec); return TEH_RESPONSE_reply_internal_error (connection, - TALER_EC_TEST_RSA_SIGN_ERROR, - "Failed to RSA-sign"); + TALER_EC_TEST_RSA_SIGN_ERROR, + "Failed to RSA-sign"); } GNUNET_JSON_parse_free (spec); res = TEH_RESPONSE_reply_json_pack (connection, - MHD_HTTP_OK, - "{s:o}", - "rsa_blind_sig", - GNUNET_JSON_from_rsa_signature (sig)); + MHD_HTTP_OK, + "{s:o}", + "rsa_blind_sig", + GNUNET_JSON_from_rsa_signature (sig)); GNUNET_CRYPTO_rsa_signature_free (sig); return res; } @@ -536,10 +538,10 @@ TEH_TEST_handler_test_rsa_sign (struct TEH_RequestHandler *rh, */ int TEH_TEST_handler_test_transfer (struct TEH_RequestHandler *rh, - struct MHD_Connection *connection, - void **connection_cls, - const char *upload_data, - size_t *upload_data_size) + struct MHD_Connection *connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size) { json_t *json; int res; @@ -562,8 +564,8 @@ TEH_TEST_handler_test_transfer (struct TEH_RequestHandler *rh, if ( (GNUNET_NO == res) || (NULL == json) ) return MHD_YES; res = TEH_PARSE_json_data (connection, - json, - spec); + json, + spec); json_decref (json); if (GNUNET_YES != res) return (GNUNET_NO == res) ? MHD_YES : MHD_NO; @@ -571,10 +573,10 @@ TEH_TEST_handler_test_transfer (struct TEH_RequestHandler *rh, &coin_pub, &secret); return TEH_RESPONSE_reply_json_pack (connection, - MHD_HTTP_OK, - "{s:o}", - "secret", - GNUNET_JSON_from_data_auto (&secret)); + MHD_HTTP_OK, + "{s:o}", + "secret", + GNUNET_JSON_from_data_auto (&secret)); } @@ -590,10 +592,10 @@ TEH_TEST_handler_test_transfer (struct TEH_RequestHandler *rh, */ int TEH_TEST_handler_test (struct TEH_RequestHandler *rh, - struct MHD_Connection *connection, - void **connection_cls, - const char *upload_data, - size_t *upload_data_size) + struct MHD_Connection *connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size) { json_t *json; int res; diff --git a/src/exchange/taler-exchange-httpd_test.h b/src/exchange/taler-exchange-httpd_test.h index e68ae2f79..d1f8f0004 100644 --- a/src/exchange/taler-exchange-httpd_test.h +++ b/src/exchange/taler-exchange-httpd_test.h @@ -43,10 +43,10 @@ */ int TEH_TEST_handler_test_base32 (struct TEH_RequestHandler *rh, - struct MHD_Connection *connection, - void **connection_cls, - const char *upload_data, - size_t *upload_data_size); + struct MHD_Connection *connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size); /** @@ -68,10 +68,10 @@ TEH_TEST_handler_test_base32 (struct TEH_RequestHandler *rh, */ int TEH_TEST_handler_test_encrypt (struct TEH_RequestHandler *rh, - struct MHD_Connection *connection, - void **connection_cls, - const char *upload_data, - size_t *upload_data_size); + struct MHD_Connection *connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size); /** @@ -93,10 +93,10 @@ TEH_TEST_handler_test_encrypt (struct TEH_RequestHandler *rh, */ int TEH_TEST_handler_test_hkdf (struct TEH_RequestHandler *rh, - struct MHD_Connection *connection, - void **connection_cls, - const char *upload_data, - size_t *upload_data_size); + struct MHD_Connection *connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size); /** @@ -115,10 +115,10 @@ TEH_TEST_handler_test_hkdf (struct TEH_RequestHandler *rh, */ int TEH_TEST_handler_test_ecdhe (struct TEH_RequestHandler *rh, - struct MHD_Connection *connection, - void **connection_cls, - const char *upload_data, - size_t *upload_data_size); + struct MHD_Connection *connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size); /** @@ -138,10 +138,10 @@ TEH_TEST_handler_test_ecdhe (struct TEH_RequestHandler *rh, */ int TEH_TEST_handler_test_eddsa (struct TEH_RequestHandler *rh, - struct MHD_Connection *connection, - void **connection_cls, - const char *upload_data, - size_t *upload_data_size); + struct MHD_Connection *connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size); /** @@ -199,10 +199,10 @@ TEH_TEST_handler_test_rsa_sign (struct TEH_RequestHandler *rh, */ int TEH_TEST_handler_test_transfer (struct TEH_RequestHandler *rh, - struct MHD_Connection *connection, - void **connection_cls, - const char *upload_data, - size_t *upload_data_size); + struct MHD_Connection *connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size); /** @@ -217,9 +217,9 @@ TEH_TEST_handler_test_transfer (struct TEH_RequestHandler *rh, */ int TEH_TEST_handler_test (struct TEH_RequestHandler *rh, - struct MHD_Connection *connection, - void **connection_cls, - const char *upload_data, - size_t *upload_data_size); + struct MHD_Connection *connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size); #endif diff --git a/src/exchange/taler-exchange-httpd_track_transaction.c b/src/exchange/taler-exchange-httpd_track_transaction.c index fdda22b8d..c89192680 100644 --- a/src/exchange/taler-exchange-httpd_track_transaction.c +++ b/src/exchange/taler-exchange-httpd_track_transaction.c @@ -40,12 +40,14 @@ */ static int reply_transfer_pending (struct MHD_Connection *connection, - struct GNUNET_TIME_Absolute planned_exec_time) + struct GNUNET_TIME_Absolute planned_exec_time) { return TEH_RESPONSE_reply_json_pack (connection, MHD_HTTP_ACCEPTED, "{s:o}", - "execution_time", GNUNET_JSON_from_time_abs (planned_exec_time)); + "execution_time", + GNUNET_JSON_from_time_abs ( + planned_exec_time)); } @@ -65,12 +67,12 @@ reply_transfer_pending (struct MHD_Connection *connection, */ static int reply_track_transaction (struct MHD_Connection *connection, - const struct GNUNET_HashCode *h_contract_terms, - const struct GNUNET_HashCode *h_wire, - const struct TALER_CoinSpendPublicKeyP *coin_pub, - const struct TALER_Amount *coin_contribution, - const struct TALER_WireTransferIdentifierRawP *wtid, - struct GNUNET_TIME_Absolute exec_time) + const struct GNUNET_HashCode *h_contract_terms, + const struct GNUNET_HashCode *h_wire, + const struct TALER_CoinSpendPublicKeyP *coin_pub, + const struct TALER_Amount *coin_contribution, + const struct TALER_WireTransferIdentifierRawP *wtid, + struct GNUNET_TIME_Absolute exec_time) { struct TALER_ConfirmWirePS cw; struct TALER_ExchangePublicKeyP pub; @@ -87,8 +89,8 @@ reply_track_transaction (struct MHD_Connection *connection, coin_contribution); if (GNUNET_OK != TEH_KS_sign (&cw.purpose, - &pub, - &sig)) + &pub, + &sig)) { return TEH_RESPONSE_reply_internal_error (connection, TALER_EC_EXCHANGE_BAD_CONFIGURATION, @@ -97,11 +99,17 @@ reply_track_transaction (struct MHD_Connection *connection, return TEH_RESPONSE_reply_json_pack (connection, MHD_HTTP_OK, "{s:o, s:o, s:o, s:o, s:o}", - "wtid", GNUNET_JSON_from_data_auto (wtid), - "execution_time", GNUNET_JSON_from_time_abs (exec_time), - "coin_contribution", TALER_JSON_from_amount (coin_contribution), - "exchange_sig", GNUNET_JSON_from_data_auto (&sig), - "exchange_pub", GNUNET_JSON_from_data_auto (&pub)); + "wtid", GNUNET_JSON_from_data_auto ( + wtid), + "execution_time", + GNUNET_JSON_from_time_abs (exec_time), + "coin_contribution", + TALER_JSON_from_amount ( + coin_contribution), + "exchange_sig", + GNUNET_JSON_from_data_auto (&sig), + "exchange_pub", + GNUNET_JSON_from_data_auto (&pub)); } @@ -173,10 +181,10 @@ struct DepositWtidContext */ static void handle_wtid_data (void *cls, - const struct TALER_WireTransferIdentifierRawP *wtid, + const struct TALER_WireTransferIdentifierRawP *wtid, const struct TALER_Amount *coin_contribution, const struct TALER_Amount *coin_fee, - struct GNUNET_TIME_Absolute execution_time) + struct GNUNET_TIME_Absolute execution_time) { struct DepositWtidContext *ctx = cls; @@ -188,8 +196,8 @@ handle_wtid_data (void *cls, } if (GNUNET_SYSERR == TALER_amount_subtract (&ctx->coin_delta, - coin_contribution, - coin_fee)) + coin_contribution, + coin_fee)) { GNUNET_break (0); ctx->pending = GNUNET_SYSERR; @@ -221,35 +229,35 @@ handle_wtid_data (void *cls, */ static enum GNUNET_DB_QueryStatus track_transaction_transaction (void *cls, - struct MHD_Connection *connection, - struct TALER_EXCHANGEDB_Session *session, - int *mhd_ret) + struct MHD_Connection *connection, + struct TALER_EXCHANGEDB_Session *session, + int *mhd_ret) { struct DepositWtidContext *ctx = cls; enum GNUNET_DB_QueryStatus qs; qs = TEH_plugin->wire_lookup_deposit_wtid (TEH_plugin->cls, - session, - &ctx->tps->h_contract_terms, - &ctx->tps->h_wire, - &ctx->tps->coin_pub, - ctx->merchant_pub, - &handle_wtid_data, - ctx); + session, + &ctx->tps->h_contract_terms, + &ctx->tps->h_wire, + &ctx->tps->coin_pub, + ctx->merchant_pub, + &handle_wtid_data, + ctx); if (0 > qs) { if (GNUNET_DB_STATUS_HARD_ERROR == qs) { GNUNET_break (0); *mhd_ret = TEH_RESPONSE_reply_internal_db_error (connection, - TALER_EC_TRACK_TRANSACTION_DB_FETCH_FAILED); + TALER_EC_TRACK_TRANSACTION_DB_FETCH_FAILED); } return qs; } if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs) { *mhd_ret = TEH_RESPONSE_reply_transaction_unknown (connection, - TALER_EC_TRACK_TRANSACTION_NOT_FOUND); + TALER_EC_TRACK_TRANSACTION_NOT_FOUND); return GNUNET_DB_STATUS_HARD_ERROR; } return qs; @@ -268,23 +276,28 @@ track_transaction_transaction (void *cls, */ static int check_and_handle_track_transaction_request (struct MHD_Connection *connection, - const struct TALER_DepositTrackPS *tps, - const struct TALER_MerchantPublicKeyP *merchant_pub, - const struct TALER_MerchantSignatureP *merchant_sig) + const struct + TALER_DepositTrackPS *tps, + const struct + TALER_MerchantPublicKeyP * + merchant_pub, + const struct + TALER_MerchantSignatureP * + merchant_sig) { struct DepositWtidContext ctx; int mhd_ret; if (GNUNET_OK != GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_MERCHANT_TRACK_TRANSACTION, - &tps->purpose, - &merchant_sig->eddsa_sig, - &merchant_pub->eddsa_pub)) + &tps->purpose, + &merchant_sig->eddsa_sig, + &merchant_pub->eddsa_pub)) { GNUNET_break_op (0); return TEH_RESPONSE_reply_signature_invalid (connection, - TALER_EC_TRACK_TRANSACTION_MERCHANT_SIGNATURE_INVALID, - "merchant_sig"); + TALER_EC_TRACK_TRANSACTION_MERCHANT_SIGNATURE_INVALID, + "merchant_sig"); } ctx.pending = GNUNET_NO; ctx.tps = tps; @@ -293,23 +306,23 @@ check_and_handle_track_transaction_request (struct MHD_Connection *connection, if (GNUNET_OK != TEH_DB_run_transaction (connection, "handle track transaction", - &mhd_ret, - &track_transaction_transaction, - &ctx)) + &mhd_ret, + &track_transaction_transaction, + &ctx)) return mhd_ret; if (GNUNET_YES == ctx.pending) return reply_transfer_pending (connection, - ctx.execution_time); + ctx.execution_time); if (GNUNET_SYSERR == ctx.pending) return TEH_RESPONSE_reply_internal_db_error (connection, - TALER_EC_TRACK_TRANSACTION_DB_FEE_INCONSISTENT); + TALER_EC_TRACK_TRANSACTION_DB_FEE_INCONSISTENT); return reply_track_transaction (connection, - &tps->h_contract_terms, - &tps->h_wire, - &tps->coin_pub, - &ctx.coin_delta, - &ctx.wtid, - ctx.execution_time); + &tps->h_contract_terms, + &tps->h_wire, + &tps->coin_pub, + &ctx.coin_delta, + &ctx.wtid, + ctx.execution_time); } diff --git a/src/exchange/taler-exchange-httpd_track_transfer.c b/src/exchange/taler-exchange-httpd_track_transfer.c index 80a29ee00..2aaeacd7e 100644 --- a/src/exchange/taler-exchange-httpd_track_transfer.c +++ b/src/exchange/taler-exchange-httpd_track_transfer.c @@ -84,12 +84,13 @@ struct TEH_TrackTransferDetail */ static int reply_track_transfer_details (struct MHD_Connection *connection, - const struct TALER_Amount *total, - const struct TALER_MerchantPublicKeyP *merchant_pub, - const struct GNUNET_HashCode *h_wire, - const struct TALER_Amount *wire_fee, - struct GNUNET_TIME_Absolute exec_time, - const struct TEH_TrackTransferDetail *wdd_head) + const struct TALER_Amount *total, + const struct + TALER_MerchantPublicKeyP *merchant_pub, + const struct GNUNET_HashCode *h_wire, + const struct TALER_Amount *wire_fee, + struct GNUNET_TIME_Absolute exec_time, + const struct TEH_TrackTransferDetail *wdd_head) { const struct TEH_TrackTransferDetail *wdd_pos; json_t *deposits; @@ -117,10 +118,19 @@ reply_track_transfer_details (struct MHD_Connection *connection, GNUNET_assert (0 == json_array_append_new (deposits, json_pack ("{s:o, s:o, s:o, s:o}", - "h_contract_terms", GNUNET_JSON_from_data_auto (&wdd_pos->h_contract_terms), - "coin_pub", GNUNET_JSON_from_data_auto (&wdd_pos->coin_pub), - "deposit_value", TALER_JSON_from_amount (&wdd_pos->deposit_value), - "deposit_fee", TALER_JSON_from_amount (&wdd_pos->deposit_fee)))); + "h_contract_terms", + GNUNET_JSON_from_data_auto ( + &wdd_pos-> + h_contract_terms), + "coin_pub", + GNUNET_JSON_from_data_auto ( + &wdd_pos->coin_pub), + "deposit_value", + TALER_JSON_from_amount ( + &wdd_pos->deposit_value), + "deposit_fee", + TALER_JSON_from_amount ( + &wdd_pos->deposit_fee)))); } wdp.purpose.purpose = htonl (TALER_SIGNATURE_EXCHANGE_CONFIRM_WIRE_DEPOSIT); wdp.purpose.size = htonl (sizeof (struct TALER_WireDepositDataPS)); @@ -134,8 +144,8 @@ reply_track_transfer_details (struct MHD_Connection *connection, &wdp.h_details); if (GNUNET_OK != TEH_KS_sign (&wdp.purpose, - &pub, - &sig)) + &pub, + &sig)) { json_decref (deposits); return TEH_RESPONSE_reply_internal_error (connection, @@ -147,13 +157,20 @@ reply_track_transfer_details (struct MHD_Connection *connection, MHD_HTTP_OK, "{s:o, s:o, s:o, s:o, s:o, s:o, s:o, s:o}", "total", TALER_JSON_from_amount (total), - "wire_fee", TALER_JSON_from_amount (wire_fee), - "merchant_pub", GNUNET_JSON_from_data_auto (merchant_pub), - "H_wire", GNUNET_JSON_from_data_auto (h_wire), - "execution_time", GNUNET_JSON_from_time_abs (exec_time), + "wire_fee", TALER_JSON_from_amount ( + wire_fee), + "merchant_pub", + GNUNET_JSON_from_data_auto ( + merchant_pub), + "H_wire", GNUNET_JSON_from_data_auto ( + h_wire), + "execution_time", + GNUNET_JSON_from_time_abs (exec_time), "deposits", deposits, - "exchange_sig", GNUNET_JSON_from_data_auto (&sig), - "exchange_pub", GNUNET_JSON_from_data_auto (&pub)); + "exchange_sig", + GNUNET_JSON_from_data_auto (&sig), + "exchange_pub", + GNUNET_JSON_from_data_auto (&pub)); } @@ -353,9 +370,9 @@ handle_transaction_data (void *cls, */ static enum GNUNET_DB_QueryStatus track_transfer_transaction (void *cls, - struct MHD_Connection *connection, - struct TALER_EXCHANGEDB_Session *session, - int *mhd_ret) + struct MHD_Connection *connection, + struct TALER_EXCHANGEDB_Session *session, + int *mhd_ret) { struct WtidTransactionContext *ctx = cls; enum GNUNET_DB_QueryStatus qs; @@ -369,17 +386,17 @@ track_transfer_transaction (void *cls, ctx->wdd_tail = NULL; ctx->wire_method = NULL; qs = TEH_plugin->lookup_wire_transfer (TEH_plugin->cls, - session, - &ctx->wtid, - &handle_transaction_data, - ctx); + session, + &ctx->wtid, + &handle_transaction_data, + ctx); if (0 > qs) { if (GNUNET_DB_STATUS_HARD_ERROR == qs) { GNUNET_break (0); *mhd_ret = TEH_RESPONSE_reply_internal_db_error (connection, - TALER_EC_TRACK_TRANSFER_DB_FETCH_FAILED); + TALER_EC_TRACK_TRANSFER_DB_FETCH_FAILED); } return qs; } @@ -387,33 +404,33 @@ track_transfer_transaction (void *cls, { GNUNET_break (0); *mhd_ret = TEH_RESPONSE_reply_internal_db_error (connection, - TALER_EC_TRACK_TRANSFER_DB_INCONSISTENT); + TALER_EC_TRACK_TRANSFER_DB_INCONSISTENT); return GNUNET_DB_STATUS_HARD_ERROR; } if (GNUNET_NO == ctx->is_valid) { *mhd_ret = TEH_RESPONSE_reply_arg_unknown (connection, - TALER_EC_TRACK_TRANSFER_WTID_NOT_FOUND, - "wtid"); + TALER_EC_TRACK_TRANSFER_WTID_NOT_FOUND, + "wtid"); return GNUNET_DB_STATUS_HARD_ERROR; } qs = TEH_plugin->get_wire_fee (TEH_plugin->cls, - session, - ctx->wire_method, - ctx->exec_time, - &wire_fee_start_date, - &wire_fee_end_date, - &ctx->wire_fee, - &closing_fee, - &wire_fee_master_sig); + session, + ctx->wire_method, + ctx->exec_time, + &wire_fee_start_date, + &wire_fee_end_date, + &ctx->wire_fee, + &closing_fee, + &wire_fee_master_sig); if (0 >= qs) { if ( (GNUNET_DB_STATUS_HARD_ERROR == qs) || - (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS) ) + (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS) ) { GNUNET_break (0); *mhd_ret = TEH_RESPONSE_reply_internal_db_error (connection, - TALER_EC_TRACK_TRANSFER_WIRE_FEE_NOT_FOUND); + TALER_EC_TRACK_TRANSFER_WIRE_FEE_NOT_FOUND); } return qs; } @@ -424,7 +441,7 @@ track_transfer_transaction (void *cls, { GNUNET_break (0); *mhd_ret = TEH_RESPONSE_reply_internal_db_error (connection, - TALER_EC_TRACK_TRANSFER_WIRE_FEE_INCONSISTENT); + TALER_EC_TRACK_TRANSFER_WIRE_FEE_INCONSISTENT); return GNUNET_DB_STATUS_HARD_ERROR; } return GNUNET_DB_STATUS_SUCCESS_ONE_RESULT; @@ -477,7 +494,8 @@ TEH_TRACKING_handler_track_transfer (struct TEH_RequestHandler *rh, res = TEH_PARSE_mhd_request_arg_data (connection, "wtid", &ctx.wtid, - sizeof (struct TALER_WireTransferIdentifierRawP)); + sizeof (struct + TALER_WireTransferIdentifierRawP)); if (GNUNET_SYSERR == res) return MHD_NO; /* internal error */ if (GNUNET_NO == res) @@ -485,20 +503,20 @@ TEH_TRACKING_handler_track_transfer (struct TEH_RequestHandler *rh, if (GNUNET_OK != TEH_DB_run_transaction (connection, "run track transfer", - &mhd_ret, - &track_transfer_transaction, - &ctx)) + &mhd_ret, + &track_transfer_transaction, + &ctx)) { free_ctx (&ctx); return mhd_ret; } mhd_ret = reply_track_transfer_details (connection, - &ctx.total, - &ctx.merchant_pub, - &ctx.h_wire, - &ctx.wire_fee, - ctx.exec_time, - ctx.wdd_head); + &ctx.total, + &ctx.merchant_pub, + &ctx.h_wire, + &ctx.wire_fee, + ctx.exec_time, + ctx.wdd_head); free_ctx (&ctx); return mhd_ret; } diff --git a/src/exchange/taler-exchange-httpd_validation.c b/src/exchange/taler-exchange-httpd_validation.c index acb121178..0be21528f 100644 --- a/src/exchange/taler-exchange-httpd_validation.c +++ b/src/exchange/taler-exchange-httpd_validation.c @@ -320,7 +320,7 @@ TEH_json_validate_wireformat (const json_t *wire, payto_url); return TALER_EC_PAYTO_MALFORMED; } - for (struct Plugin *p=wire_head; NULL != p; p = p->next) + for (struct Plugin *p = wire_head; NULL != p; p = p->next) { if (0 == strcasecmp (p->plugin->method, method)) diff --git a/src/exchange/taler-exchange-httpd_wire.c b/src/exchange/taler-exchange-httpd_wire.c index bbbf3fb48..797ed8bed 100644 --- a/src/exchange/taler-exchange-httpd_wire.c +++ b/src/exchange/taler-exchange-httpd_wire.c @@ -57,11 +57,19 @@ fees_to_json (struct TALER_EXCHANGEDB_AggregateFees *af) if (0 != json_array_append_new (a, json_pack ("{s:o, s:o, s:o, s:o, s:o}", - "wire_fee", TALER_JSON_from_amount (&af->wire_fee), - "closing_fee", TALER_JSON_from_amount (&af->closing_fee), - "start_date", GNUNET_JSON_from_time_abs (af->start_date), - "end_date", GNUNET_JSON_from_time_abs (af->end_date), - "sig", GNUNET_JSON_from_data_auto (&af->master_sig)))) + "wire_fee", TALER_JSON_from_amount ( + &af->wire_fee), + "closing_fee", + TALER_JSON_from_amount ( + &af->closing_fee), + "start_date", + GNUNET_JSON_from_time_abs ( + af->start_date), + "end_date", + GNUNET_JSON_from_time_abs ( + af->end_date), + "sig", GNUNET_JSON_from_data_auto ( + &af->master_sig)))) { GNUNET_break (0); json_decref (a); @@ -157,7 +165,7 @@ TEH_WIRE_init () /** * Clean up wire subsystem. */ -void __attribute__ ((destructor)) +void __attribute__ ((destructor)) TEH_wire_cleanup () { if (NULL != wire_methods) diff --git a/src/exchange/taler-exchange-wirewatch.c b/src/exchange/taler-exchange-wirewatch.c index ac2d96a0b..ea737b7b5 100644 --- a/src/exchange/taler-exchange-wirewatch.c +++ b/src/exchange/taler-exchange-wirewatch.c @@ -216,8 +216,9 @@ shutdown_task (void *cls) { char *wtid_s; - wtid_s = wa_pos->wire_plugin->reject_transfer_cancel (wa_pos->wire_plugin->cls, - rt); + wtid_s = wa_pos->wire_plugin->reject_transfer_cancel ( + wa_pos->wire_plugin->cls, + rt); rt = NULL; GNUNET_free (wtid_s); } @@ -262,8 +263,8 @@ add_account_cb (void *cls, if (NULL == wa->wire_plugin) { GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, - "Failed to load wire plugin for `%s'\n", - ai->plugin_name); + "Failed to load wire plugin for `%s'\n", + ai->plugin_name); GNUNET_free (wa); return; } @@ -355,7 +356,7 @@ reject_cb (void *cls, ec); GNUNET_free (rtc->wtid_s); db_plugin->rollback (db_plugin->cls, - rtc->session); + rtc->session); GNUNET_free (rtc); GNUNET_SCHEDULER_shutdown (); return; @@ -385,10 +386,10 @@ reject_cb (void *cls, static int history_cb (void *cls, enum TALER_ErrorCode ec, - enum TALER_BANK_Direction dir, - const void *row_off, - size_t row_off_size, - const struct TALER_WIRE_TransferDetails *details) + enum TALER_BANK_Direction dir, + const void *row_off, + size_t row_off_size, + const struct TALER_WIRE_TransferDetails *details) { struct TALER_EXCHANGEDB_Session *session = cls; enum GNUNET_DB_QueryStatus qs; @@ -409,7 +410,7 @@ history_cb (void *cls, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "End of list. Committing progress!\n"); qs = db_plugin->commit (db_plugin->cls, - session); + session); if (GNUNET_DB_STATUS_SOFT_ERROR == qs) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, @@ -529,14 +530,14 @@ history_cb (void *cls, &details->wtid, sizeof (reserve_pub)); qs = db_plugin->reserves_in_insert (db_plugin->cls, - session, - &reserve_pub, - &details->amount, - details->execution_date, - details->account_url, + session, + &reserve_pub, + &details->amount, + details->execution_date, + details->account_url, wa_pos->section_name, - row_off, - row_off_size); + row_off, + row_off_size); if (GNUNET_DB_STATUS_HARD_ERROR == qs) { GNUNET_break (0); @@ -554,7 +555,7 @@ history_cb (void *cls, /* try again */ GNUNET_assert (NULL == task); task = GNUNET_SCHEDULER_add_now (&find_transfers, - NULL); + NULL); return GNUNET_SYSERR; } @@ -565,8 +566,8 @@ history_cb (void *cls, latest_row_off_size = row_off_size; } memcpy (latest_row_off, - row_off, - row_off_size); + row_off, + row_off_size); return GNUNET_OK; } @@ -705,24 +706,25 @@ main (int argc, { struct GNUNET_GETOPT_CommandLineOption options[] = { GNUNET_GETOPT_option_flag ('T', - "test", - "run in test mode and exit when idle", - &test_mode), + "test", + "run in test mode and exit when idle", + &test_mode), GNUNET_GETOPT_option_flag ('r', - "reset", - "start fresh with all transactions in the history", - &reset_mode), + "reset", + "start fresh with all transactions in the history", + &reset_mode), GNUNET_GETOPT_OPTION_END }; if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, - &argc, &argv)) + &argc, &argv)) return 2; if (GNUNET_OK != GNUNET_PROGRAM_run (argc, argv, "taler-exchange-wirewatch", - gettext_noop ("background process that watches for incomming wire transfers from customers"), + gettext_noop ( + "background process that watches for incomming wire transfers from customers"), options, &run, NULL)) { diff --git a/src/exchange/test_taler_exchange_aggregator.c b/src/exchange/test_taler_exchange_aggregator.c index b02c976af..274a28ac7 100644 --- a/src/exchange/test_taler_exchange_aggregator.c +++ b/src/exchange/test_taler_exchange_aggregator.c @@ -32,7 +32,8 @@ /** * Commands for the interpreter. */ -enum OpCode { +enum OpCode +{ /** * Terminate testcase with 'skipped' result. @@ -86,14 +87,16 @@ struct Command */ const char *label; - union { + union + { /** * If @e opcode is #OPCODE_EXPECT_TRANSACTION, this * specifies which transaction we expected. Note that * the WTID will be set, not checked! */ - struct { + struct + { /** * Amount to be transferred. @@ -126,7 +129,8 @@ struct Command * If @e opcode is #OPCODE_DATABASE_DEPOST, this * specifies which deposit operation we should fake. */ - struct { + struct + { /** * Each merchant name is automatically mapped to a unique @@ -174,7 +178,7 @@ struct State /** * Array of commands to run. */ - struct Command* commands; + struct Command*commands; /** * Offset of the next command to be run. @@ -339,9 +343,10 @@ maint_child_death (void *cls) aggregator_state->ioff++; state = aggregator_state; aggregator_state = NULL; - child_death_task = GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, - pr, - &maint_child_death, NULL); + child_death_task = GNUNET_SCHEDULER_add_read_file ( + GNUNET_TIME_UNIT_FOREVER_REL, + pr, + &maint_child_death, NULL); interpreter (state); } @@ -354,7 +359,8 @@ maint_child_death (void *cls) static void fake_issue (struct TALER_EXCHANGEDB_DenominationKeyInformationP *issue) { - memset (issue, 0, sizeof (struct TALER_EXCHANGEDB_DenominationKeyInformationP)); + memset (issue, 0, sizeof (struct + TALER_EXCHANGEDB_DenominationKeyInformationP)); GNUNET_assert (GNUNET_OK == TALER_string_to_amount_nbo ("EUR:1", &issue->properties.value)); @@ -440,7 +446,8 @@ do_deposit (struct Command *cmd) GNUNET_asprintf (&str, "payto://x-taler-bank/localhost:8082/%llu", - (unsigned long long) cmd->details.deposit.merchant_account); + (unsigned long + long) cmd->details.deposit.merchant_account); deposit.receiver_wire_account = json_pack ("{s:s, s:s}", "salt", "this-is-a-salt-value", @@ -448,11 +455,13 @@ do_deposit (struct Command *cmd) GNUNET_free (str); } GNUNET_assert (GNUNET_OK == - TALER_JSON_merchant_wire_signature_hash (deposit.receiver_wire_account, - &deposit.h_wire)); + TALER_JSON_merchant_wire_signature_hash ( + deposit.receiver_wire_account, + &deposit.h_wire)); deposit.timestamp = GNUNET_TIME_absolute_get (); GNUNET_TIME_round_abs (&deposit.timestamp); - deposit.wire_deadline = GNUNET_TIME_relative_to_absolute (cmd->details.deposit.wire_deadline); + deposit.wire_deadline = GNUNET_TIME_relative_to_absolute ( + cmd->details.deposit.wire_deadline); GNUNET_TIME_round_abs (&deposit.wire_deadline); /* finally, actually perform the DB operation */ @@ -550,7 +559,7 @@ interpreter (void *cls) fail (cmd); return; } - return; + return; case OPCODE_EXPECT_TRANSACTIONS_EMPTY: if (GNUNET_OK != TALER_FAKEBANK_check_empty (fb)) { @@ -585,7 +594,8 @@ interpreter (void *cls) &want_amount, cmd->details.expect_transaction.debit_account, cmd->details.expect_transaction.credit_account, - cmd->details.expect_transaction.exchange_base_url, + cmd->details.expect_transaction. + exchange_base_url, &cmd->details.expect_transaction.subject)) { fail (cmd); @@ -641,7 +651,8 @@ run_test () .label = "expect-deposit-1", .details.expect_transaction.debit_account = 3, .details.expect_transaction.credit_account = 4, - .details.expect_transaction.exchange_base_url = "https://exchange.taler.net/", + .details.expect_transaction.exchange_base_url = + "https://exchange.taler.net/", .details.expect_transaction.amount = "EUR:0.89" }, @@ -688,7 +699,8 @@ run_test () .label = "expect-deposit-2", .details.expect_transaction.debit_account = 3, .details.expect_transaction.credit_account = 4, - .details.expect_transaction.exchange_base_url = "https://exchange.taler.net/", + .details.expect_transaction.exchange_base_url = + "https://exchange.taler.net/", .details.expect_transaction.amount = "EUR:1.79" }, @@ -734,7 +746,8 @@ run_test () .label = "expect-deposit-3a", .details.expect_transaction.debit_account = 3, .details.expect_transaction.credit_account = 4, - .details.expect_transaction.exchange_base_url = "https://exchange.taler.net/", + .details.expect_transaction.exchange_base_url = + "https://exchange.taler.net/", .details.expect_transaction.amount = "EUR:0.89" }, { @@ -742,7 +755,8 @@ run_test () .label = "expect-deposit-3b", .details.expect_transaction.debit_account = 3, .details.expect_transaction.credit_account = 4, - .details.expect_transaction.exchange_base_url = "https://exchange.taler.net/", + .details.expect_transaction.exchange_base_url = + "https://exchange.taler.net/", .details.expect_transaction.amount = "EUR:0.89" }, { @@ -750,7 +764,8 @@ run_test () .label = "expect-deposit-3c", .details.expect_transaction.debit_account = 3, .details.expect_transaction.credit_account = 5, - .details.expect_transaction.exchange_base_url = "https://exchange.taler.net/", + .details.expect_transaction.exchange_base_url = + "https://exchange.taler.net/", .details.expect_transaction.amount = "EUR:0.89" }, { @@ -799,7 +814,8 @@ run_test () .label = "expect-deposit-4", .details.expect_transaction.debit_account = 3, .details.expect_transaction.credit_account = 4, - .details.expect_transaction.exchange_base_url = "https://exchange.taler.net/", + .details.expect_transaction.exchange_base_url = + "https://exchange.taler.net/", .details.expect_transaction.amount = "EUR:0.19" }, @@ -844,7 +860,8 @@ run_test () .label = "expect-deposit-5", .details.expect_transaction.debit_account = 3, .details.expect_transaction.credit_account = 4, - .details.expect_transaction.exchange_base_url = "https://exchange.taler.net/", + .details.expect_transaction.exchange_base_url = + "https://exchange.taler.net/", .details.expect_transaction.amount = "EUR:0.19" }, @@ -927,7 +944,8 @@ run_test () .label = "expect-deposit-6", .details.expect_transaction.debit_account = 3, .details.expect_transaction.credit_account = 4, - .details.expect_transaction.exchange_base_url = "https://exchange.taler.net/", + .details.expect_transaction.exchange_base_url = + "https://exchange.taler.net/", .details.expect_transaction.amount = "EUR:0.01" }, @@ -967,7 +985,8 @@ run_test () .label = "expect-deposit-7", .details.expect_transaction.debit_account = 3, .details.expect_transaction.credit_account = 4, - .details.expect_transaction.exchange_base_url = "https://exchange.taler.net/", + .details.expect_transaction.exchange_base_url = + "https://exchange.taler.net/", .details.expect_transaction.amount = "EUR:0.01" }, /* Now check profit was actually taken */ @@ -989,7 +1008,8 @@ run_test () .label = "expect-deposit-7", .details.expect_transaction.debit_account = 3, .details.expect_transaction.credit_account = 4, - .details.expect_transaction.exchange_base_url = "https://exchange.taler.net/", + .details.expect_transaction.exchange_base_url = + "https://exchange.taler.net/", .details.expect_transaction.amount = "EUR:0.01" }, @@ -1047,7 +1067,8 @@ run_test () .label = "expect-deposit-8", .details.expect_transaction.debit_account = 3, .details.expect_transaction.credit_account = 4, - .details.expect_transaction.exchange_base_url = "https://exchange.taler.net/", + .details.expect_transaction.exchange_base_url = + "https://exchange.taler.net/", .details.expect_transaction.amount = "EUR:0.03" }, @@ -1107,7 +1128,8 @@ run_test () .label = "expect-deposit-9", .details.expect_transaction.debit_account = 3, .details.expect_transaction.credit_account = 4, - .details.expect_transaction.exchange_base_url = "https://exchange.taler.net/", + .details.expect_transaction.exchange_base_url = + "https://exchange.taler.net/", .details.expect_transaction.amount = "EUR:0.01" }, @@ -1166,7 +1188,7 @@ run (void *cls) fake_issue (&issue); dpk.rsa_public_key = coin_pub; GNUNET_CRYPTO_rsa_public_key_hash (dpk.rsa_public_key, - &issue.properties.denom_hash); + &issue.properties.denom_hash); if ( (GNUNET_OK != plugin->start (plugin->cls, session, @@ -1179,18 +1201,18 @@ run (void *cls) (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS != plugin->commit (plugin->cls, session)) ) - { - GNUNET_break (0); - TALER_EXCHANGEDB_plugin_unload (plugin); - plugin = NULL; - result = 77; - return; - } + { + GNUNET_break (0); + TALER_EXCHANGEDB_plugin_unload (plugin); + plugin = NULL; + result = 77; + return; + } child_death_task = GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, - GNUNET_DISK_pipe_handle (sigpipe, - GNUNET_DISK_PIPE_END_READ), - &maint_child_death, + GNUNET_DISK_pipe_handle (sigpipe, + GNUNET_DISK_PIPE_END_READ), + &maint_child_death, NULL); GNUNET_SCHEDULER_add_shutdown (&shutdown_action, NULL); @@ -1217,13 +1239,13 @@ static void sighandler_child_death () { static char c; - int old_errno = errno; /* back-up errno */ + int old_errno = errno; /* back-up errno */ GNUNET_break (1 == - GNUNET_DISK_file_write (GNUNET_DISK_pipe_handle - (sigpipe, GNUNET_DISK_PIPE_END_WRITE), - &c, sizeof (c))); - errno = old_errno; /* restore errno */ + GNUNET_DISK_file_write (GNUNET_DISK_pipe_handle + (sigpipe, GNUNET_DISK_PIPE_END_WRITE), + &c, sizeof (c))); + errno = old_errno; /* restore errno */ } @@ -1266,14 +1288,14 @@ main (int argc, if (NULL == proc) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Failed to run `taler-exchange-keyup`, is your PATH correct?\n"); + "Failed to run `taler-exchange-keyup`, is your PATH correct?\n"); return 77; } GNUNET_OS_process_wait (proc); GNUNET_OS_process_destroy (proc); if (GNUNET_OK != GNUNET_NETWORK_test_port_free (IPPROTO_TCP, - 8082)) + 8082)) { fprintf (stderr, "Required port %u not available, skipping.\n", diff --git a/src/exchange/test_taler_exchange_wirewatch.c b/src/exchange/test_taler_exchange_wirewatch.c index 4a23bdb5c..27b98bb06 100644 --- a/src/exchange/test_taler_exchange_wirewatch.c +++ b/src/exchange/test_taler_exchange_wirewatch.c @@ -34,7 +34,8 @@ /** * Commands for the interpreter. */ -enum OpCode { +enum OpCode +{ /** * Terminate testcase with 'skipped' result. @@ -94,14 +95,16 @@ struct Command */ const char *label; - union { + union + { /** * If @e opcode is #OPCODE_EXPECT_TRANSFER, this * specifies which transaction we expected. Note that * the WTID will be set, not checked! */ - struct { + struct + { /** * Amount to be transferred. @@ -135,7 +138,8 @@ struct Command * If @e opcode is #OPCODE_RUN_TRANSFER, this * specifies which transaction the bank should do. */ - struct { + struct + { /** * Amount to be transferred. @@ -164,7 +168,8 @@ struct Command } run_transfer; - struct { + struct + { /** * The handle for the aggregator process that we are testing. @@ -178,7 +183,8 @@ struct Command } aggregator; - struct { + struct + { /** * The handle for the wirewatch process that we are testing. @@ -210,7 +216,7 @@ struct State /** * Array of commands to run. */ - struct Command* commands; + struct Command*commands; /** * Offset of the next command to be run. @@ -335,7 +341,7 @@ shutdown_action (void *cls) TALER_FAKEBANK_stop (fb); fb = NULL; } - for (unsigned int i=0;i<=state->ioff;i++) + for (unsigned int i = 0; i<=state->ioff; i++) { struct Command *cmd = &state->commands[i]; @@ -351,8 +357,9 @@ shutdown_action (void *cls) } if (NULL != cmd->details.aggregator.aggregator_proc) { - GNUNET_break (0 == GNUNET_OS_process_kill (cmd->details.aggregator.aggregator_proc, - SIGKILL)); + GNUNET_break (0 == GNUNET_OS_process_kill ( + cmd->details.aggregator.aggregator_proc, + SIGKILL)); GNUNET_OS_process_wait (cmd->details.aggregator.aggregator_proc); GNUNET_OS_process_destroy (cmd->details.aggregator.aggregator_proc); cmd->details.aggregator.aggregator_proc = NULL; @@ -366,8 +373,9 @@ shutdown_action (void *cls) } if (NULL != cmd->details.wirewatch.wirewatch_proc) { - GNUNET_break (0 == GNUNET_OS_process_kill (cmd->details.wirewatch.wirewatch_proc, - SIGKILL)); + GNUNET_break (0 == GNUNET_OS_process_kill ( + cmd->details.wirewatch.wirewatch_proc, + SIGKILL)); GNUNET_OS_process_wait (cmd->details.wirewatch.wirewatch_proc); GNUNET_OS_process_destroy (cmd->details.wirewatch.wirewatch_proc); cmd->details.wirewatch.wirewatch_proc = NULL; @@ -614,7 +622,8 @@ run (void *cls) .label = "run-transfer-good-to-exchange", .details.run_transfer.debit_account = 4, .details.run_transfer.credit_account = 3, - .details.run_transfer.subject = "SRB8VQHNTNJWSSG7BXT24Z063ZSXN7T0MHCQCBAFC1V17BZH10D0", + .details.run_transfer.subject = + "SRB8VQHNTNJWSSG7BXT24Z063ZSXN7T0MHCQCBAFC1V17BZH10D0", .details.run_transfer.amount = "EUR:5.00" }, /* creates reserve */ @@ -628,7 +637,8 @@ run (void *cls) .label = "clear-good-transfer-to-exchange", .details.expect_transfer.debit_account = 4, .details.expect_transfer.credit_account = 3, - .details.expect_transfer.exchange_base_url = "https://exchange.taler.net/", + .details.expect_transfer.exchange_base_url = + "https://exchange.taler.net/", .details.expect_transfer.amount = "EUR:5.00" }, /* should do NOTHING, it is too early... */ @@ -658,7 +668,8 @@ run (void *cls) .label = "check-reserve-expiration-transfer", .details.expect_transfer.debit_account = 3, .details.expect_transfer.credit_account = 4, - .details.expect_transfer.exchange_base_url = "https://exchange.taler.net/", + .details.expect_transfer.exchange_base_url = + "https://exchange.taler.net/", .details.expect_transfer.amount = "EUR:4.99" }, /* check nothing else happened */ @@ -685,7 +696,8 @@ run (void *cls) .label = "expect-bad-transfer-to-exchange", .details.expect_transfer.debit_account = 4, .details.expect_transfer.credit_account = 3, - .details.expect_transfer.exchange_base_url = "https://exchange.taler.net/", + .details.expect_transfer.exchange_base_url = + "https://exchange.taler.net/", .details.expect_transfer.amount = "EUR:5.00" }, { @@ -693,7 +705,8 @@ run (void *cls) .label = "expect-rewire-transfer-from-exchange", .details.expect_transfer.debit_account = 3, .details.expect_transfer.credit_account = 4, - .details.expect_transfer.exchange_base_url = "https://exchange.taler.net/", + .details.expect_transfer.exchange_base_url = + "https://exchange.taler.net/", .details.expect_transfer.amount = "EUR:5.00" }, { @@ -739,13 +752,13 @@ static void sighandler_child_death () { static char c; - int old_errno = errno; /* back-up errno */ + int old_errno = errno; /* back-up errno */ GNUNET_break (1 == - GNUNET_DISK_file_write (GNUNET_DISK_pipe_handle - (sigpipe, GNUNET_DISK_PIPE_END_WRITE), - &c, sizeof (c))); - errno = old_errno; /* restore errno */ + GNUNET_DISK_file_write (GNUNET_DISK_pipe_handle + (sigpipe, GNUNET_DISK_PIPE_END_WRITE), + &c, sizeof (c))); + errno = old_errno; /* restore errno */ } @@ -788,7 +801,7 @@ main (int argc, if (NULL == proc) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Failed to run `taler-exchange-keyup`, is your PATH correct?\n"); + "Failed to run `taler-exchange-keyup`, is your PATH correct?\n"); return 77; } GNUNET_OS_process_wait (proc); @@ -804,14 +817,14 @@ main (int argc, if (NULL == proc) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Failed to run `taler-exchange-keyup`, is your PATH correct?\n"); + "Failed to run `taler-exchange-keyup`, is your PATH correct?\n"); return 77; } GNUNET_OS_process_wait (proc); GNUNET_OS_process_destroy (proc); if (GNUNET_OK != GNUNET_NETWORK_test_port_free (IPPROTO_TCP, - 8082)) + 8082)) { fprintf (stderr, "Required port %u not available, skipping.\n", diff --git a/src/exchangedb/exchangedb_accounts.c b/src/exchangedb/exchangedb_accounts.c index 10328fbe3..f336b53a4 100644 --- a/src/exchangedb/exchangedb_accounts.c +++ b/src/exchangedb/exchangedb_accounts.c @@ -100,7 +100,7 @@ check_for_account (void *cls, ai.plugin_name = plugin_name; ai.payto_url = payto_url; ai.wire_response_filename = wire_response_filename; - + ai.debit_enabled = (GNUNET_YES == GNUNET_CONFIGURATION_get_value_yesno (ctx->cfg, section, diff --git a/src/exchangedb/exchangedb_auditorkeys.c b/src/exchangedb/exchangedb_auditorkeys.c index 38498d9b5..6546c1a3f 100644 --- a/src/exchangedb/exchangedb_auditorkeys.c +++ b/src/exchangedb/exchangedb_auditorkeys.c @@ -141,8 +141,8 @@ auditor_iter (void *cls, return GNUNET_OK; } if ( (size - sizeof (struct AuditorFileHeaderP)) / dki_len < - (sizeof (struct TALER_DenominationKeyValidityPS) + - sizeof (struct TALER_AuditorSignatureP)) ) + (sizeof (struct TALER_DenominationKeyValidityPS) + + sizeof (struct TALER_AuditorSignatureP)) ) { GNUNET_break_op (0); GNUNET_log (GNUNET_ERROR_TYPE_WARNING, @@ -152,9 +152,9 @@ auditor_iter (void *cls, return GNUNET_OK; } url_len = size - - sizeof (struct AuditorFileHeaderP) - - dki_len * (sizeof (struct TALER_DenominationKeyValidityPS) + - sizeof (struct TALER_AuditorSignatureP)); + - sizeof (struct AuditorFileHeaderP) + - dki_len * (sizeof (struct TALER_DenominationKeyValidityPS) + + sizeof (struct TALER_AuditorSignatureP)); sigs = (const struct TALER_AuditorSignatureP *) &af[1]; dki = (const struct TALER_DenominationKeyValidityPS *) &sigs[dki_len]; auditor_url = (const char *) &dki[dki_len]; @@ -171,12 +171,12 @@ auditor_iter (void *cls, /* Ignoring return value to not interrupt the iteration */ if (GNUNET_OK != (iret = aic->it (aic->it_cls, - &af->apub, - auditor_url, - &af->mpub, - dki_len, - sigs, - dki))) + &af->apub, + auditor_url, + &af->mpub, + dki_len, + sigs, + dki))) { GNUNET_free (af); if (GNUNET_SYSERR == iret) @@ -248,7 +248,8 @@ TALER_EXCHANGEDB_auditor_write (const char *filename, const struct TALER_AuditorSignatureP *asigs, const struct TALER_MasterPublicKeyP *mpub, unsigned int dki_len, - const struct TALER_DenominationKeyValidityPS *dki) + const struct + TALER_DenominationKeyValidityPS *dki) { struct AuditorFileHeaderP af; struct GNUNET_DISK_FileHandle *fh; @@ -262,9 +263,11 @@ TALER_EXCHANGEDB_auditor_write (const char *filename, af.dki_len = htonl ((uint32_t) dki_len); ret = GNUNET_SYSERR; if (NULL == (fh = GNUNET_DISK_file_open - (filename, - GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE | GNUNET_DISK_OPEN_TRUNCATE, - GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE))) + (filename, + GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE + | GNUNET_DISK_OPEN_TRUNCATE, + GNUNET_DISK_PERM_USER_READ + | GNUNET_DISK_PERM_USER_WRITE))) goto cleanup; wsize = sizeof (struct AuditorFileHeaderP); if (GNUNET_SYSERR == (wrote = GNUNET_DISK_file_write (fh, @@ -291,7 +294,7 @@ TALER_EXCHANGEDB_auditor_write (const char *filename, auditor_url, wsize)) ret = GNUNET_OK; - cleanup: + cleanup: eno = errno; if (NULL != fh) (void) GNUNET_DISK_file_close (fh); diff --git a/src/exchangedb/exchangedb_denomkeys.c b/src/exchangedb/exchangedb_denomkeys.c index d9e604ebe..be2ee66b2 100644 --- a/src/exchangedb/exchangedb_denomkeys.c +++ b/src/exchangedb/exchangedb_denomkeys.c @@ -59,8 +59,10 @@ GNUNET_NETWORK_STRUCT_END */ int TALER_EXCHANGEDB_denomination_key_revoke (const char *revocation_dir, - const struct GNUNET_HashCode *denom_hash, - const struct TALER_MasterPrivateKeyP *mpriv) + const struct + GNUNET_HashCode *denom_hash, + const struct + TALER_MasterPrivateKeyP *mpriv) { struct TALER_MasterDenominationKeyRevocationPS rm; char *fn; @@ -69,7 +71,7 @@ TALER_EXCHANGEDB_denomination_key_revoke (const char *revocation_dir, ret = GNUNET_SYSERR; GNUNET_asprintf (&fn, - "%s" DIR_SEPARATOR_STR + "%s" DIR_SEPARATOR_STR "%s.rev", revocation_dir, GNUNET_h2s_full (denom_hash)); @@ -83,9 +85,10 @@ TALER_EXCHANGEDB_denomination_key_revoke (const char *revocation_dir, rd.denom_hash = *denom_hash; if (sizeof (rd) != GNUNET_DISK_fn_write (fn, - &rd, - sizeof (rd), - GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE)) + &rd, + sizeof (rd), + GNUNET_DISK_PERM_USER_READ + | GNUNET_DISK_PERM_USER_WRITE)) ret = GNUNET_SYSERR; else ret = GNUNET_OK; @@ -104,7 +107,9 @@ TALER_EXCHANGEDB_denomination_key_revoke (const char *revocation_dir, */ int TALER_EXCHANGEDB_denomination_key_read (const char *filename, - struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *dki) + struct + TALER_EXCHANGEDB_DenominationKeyIssueInformation + *dki) { uint64_t size; size_t offset; @@ -156,7 +161,8 @@ TALER_EXCHANGEDB_denomination_key_read (const char *filename, offset); GNUNET_free (data); if (0 == GNUNET_TIME_absolute_get_remaining - (GNUNET_TIME_absolute_ntoh (dki->issue.properties.expire_withdraw)).rel_value_us) + (GNUNET_TIME_absolute_ntoh ( + dki->issue.properties.expire_withdraw)).rel_value_us) { if (0 != UNLINK (filename)) { @@ -180,7 +186,9 @@ TALER_EXCHANGEDB_denomination_key_read (const char *filename, */ int TALER_EXCHANGEDB_denomination_key_write (const char *filename, - const struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *dki) + const struct + TALER_EXCHANGEDB_DenominationKeyIssueInformation + *dki) { char *priv_enc; size_t priv_enc_size; @@ -198,9 +206,11 @@ TALER_EXCHANGEDB_denomination_key_write (const char *filename, GNUNET_DISK_directory_create_for_file (filename)) return GNUNET_SYSERR; if (NULL == (fh = GNUNET_DISK_file_open - (filename, - GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE | GNUNET_DISK_OPEN_TRUNCATE, - GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE | GNUNET_DISK_OPEN_FAILIFEXISTS))) + (filename, + GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE + | GNUNET_DISK_OPEN_TRUNCATE, + GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE + | GNUNET_DISK_OPEN_FAILIFEXISTS))) goto cleanup; wsize = sizeof (struct TALER_EXCHANGEDB_DenominationKeyInformationP); if (GNUNET_SYSERR == (wrote = GNUNET_DISK_file_write (fh, @@ -217,7 +227,7 @@ TALER_EXCHANGEDB_denomination_key_write (const char *filename, if (wrote != priv_enc_size) goto cleanup; ret = GNUNET_OK; - cleanup: + cleanup: GNUNET_free_non_null (priv_enc); if (NULL != fh) (void) GNUNET_DISK_file_close (fh); @@ -328,7 +338,8 @@ denomkeys_iterate_topdir_iter (void *cls, */ int TALER_EXCHANGEDB_denomination_keys_iterate (const char *exchange_base_dir, - TALER_EXCHANGEDB_DenominationKeyIterator it, + TALER_EXCHANGEDB_DenominationKeyIterator + it, void *it_cls) { char *dir; @@ -336,7 +347,8 @@ TALER_EXCHANGEDB_denomination_keys_iterate (const char *exchange_base_dir, int ret; GNUNET_asprintf (&dir, - "%s" DIR_SEPARATOR_STR TALER_EXCHANGEDB_DIR_DENOMINATION_KEYS, + "%s" DIR_SEPARATOR_STR + TALER_EXCHANGEDB_DIR_DENOMINATION_KEYS, exchange_base_dir); dic.it = it; dic.it_cls = it_cls; @@ -363,7 +375,7 @@ struct RevocationsIterateContext * Closure for @e it. */ void *it_cls; - + /** * Master public key to use to validate revocations. */ @@ -385,7 +397,7 @@ struct RevocationsIterateContext */ static int revocations_iterate_cb (void *cls, - const char *filename) + const char *filename) { struct RevocationsIterateContext *ric = cls; struct RevocationFileP rf; @@ -394,34 +406,37 @@ revocations_iterate_cb (void *cls, /* Check if revocation is valid... */ if (sizeof (rf) != GNUNET_DISK_fn_read (filename, - &rf, - sizeof (rf))) + &rf, + sizeof (rf))) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - _("Invalid revocation file `%s' found and ignored (bad size)\n"), - filename); + _ ( + "Invalid revocation file `%s' found and ignored (bad size)\n"), + filename); return GNUNET_OK; } rm.purpose.purpose = htonl (TALER_SIGNATURE_MASTER_DENOMINATION_KEY_REVOKED); rm.purpose.size = htonl (sizeof (rm)); rm.h_denom_pub = rf.denom_hash; if (GNUNET_OK != - GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_MASTER_DENOMINATION_KEY_REVOKED, - &rm.purpose, - &rf.msig.eddsa_signature, - &ric->master_pub->eddsa_pub)) + GNUNET_CRYPTO_eddsa_verify ( + TALER_SIGNATURE_MASTER_DENOMINATION_KEY_REVOKED, + &rm.purpose, + &rf.msig.eddsa_signature, + &ric->master_pub->eddsa_pub)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - _("Invalid revocation file `%s' found and ignored (bad signature)\n"), - filename); + _ ( + "Invalid revocation file `%s' found and ignored (bad signature)\n"), + filename); return GNUNET_OK; } GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Denomination key `%s' was revoked!\n", - GNUNET_h2s (&rm.h_denom_pub)); + "Denomination key `%s' was revoked!\n", + GNUNET_h2s (&rm.h_denom_pub)); return ric->it (ric->it_cls, - &rm.h_denom_pub, - &rf.msig); + &rm.h_denom_pub, + &rf.msig); } @@ -439,9 +454,10 @@ revocations_iterate_cb (void *cls, */ int TALER_EXCHANGEDB_revocations_iterate (const char *revocation_dir, - const struct TALER_MasterPublicKeyP *master_pub, - TALER_EXCHANGEDB_RevocationIterator it, - void *it_cls) + const struct + TALER_MasterPublicKeyP *master_pub, + TALER_EXCHANGEDB_RevocationIterator it, + void *it_cls) { struct RevocationsIterateContext ric = { .it = it, @@ -452,10 +468,10 @@ TALER_EXCHANGEDB_revocations_iterate (const char *revocation_dir, if (GNUNET_OK != GNUNET_DISK_directory_create (revocation_dir)) return 0; /* directory doesn't exist and we couldn't even create it, - clearly means there are no revocations there */ + clearly means there are no revocations there */ return GNUNET_DISK_directory_scan (revocation_dir, - &revocations_iterate_cb, - &ric); + &revocations_iterate_cb, + &ric); } diff --git a/src/exchangedb/exchangedb_fees.c b/src/exchangedb/exchangedb_fees.c index d6fdac4de..f06be73ad 100644 --- a/src/exchangedb/exchangedb_fees.c +++ b/src/exchangedb/exchangedb_fees.c @@ -191,11 +191,11 @@ TALER_EXCHANGEDB_fees_write (const char *filename, return GNUNET_SYSERR; fh = GNUNET_DISK_file_open (filename, - GNUNET_DISK_OPEN_WRITE | - GNUNET_DISK_OPEN_TRUNCATE | - GNUNET_DISK_OPEN_CREATE, - GNUNET_DISK_PERM_USER_READ | - GNUNET_DISK_PERM_USER_WRITE); + GNUNET_DISK_OPEN_WRITE + | GNUNET_DISK_OPEN_TRUNCATE + | GNUNET_DISK_OPEN_CREATE, + GNUNET_DISK_PERM_USER_READ + | GNUNET_DISK_PERM_USER_WRITE); if (NULL == fh) return GNUNET_SYSERR; diff --git a/src/exchangedb/exchangedb_signkeys.c b/src/exchangedb/exchangedb_signkeys.c index cb16ee49d..10e4f7a65 100644 --- a/src/exchangedb/exchangedb_signkeys.c +++ b/src/exchangedb/exchangedb_signkeys.c @@ -63,18 +63,20 @@ signkeys_iterate_dir_iter (void *cls, nread = GNUNET_DISK_fn_read (filename, &issue, - sizeof (struct TALER_EXCHANGEDB_PrivateSigningKeyInformationP)); + sizeof (struct + TALER_EXCHANGEDB_PrivateSigningKeyInformationP)); if (nread != sizeof (struct TALER_EXCHANGEDB_PrivateSigningKeyInformationP)) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Invalid signkey file `%s': wrong size (%d, expected %u)\n", filename, (int) nread, - (unsigned int) sizeof (struct TALER_EXCHANGEDB_PrivateSigningKeyInformationP)); + (unsigned int) sizeof (struct + TALER_EXCHANGEDB_PrivateSigningKeyInformationP)); return GNUNET_OK; } if (0 == GNUNET_TIME_absolute_get_remaining - (GNUNET_TIME_absolute_ntoh (issue.issue.expire)).rel_value_us) + (GNUNET_TIME_absolute_ntoh (issue.issue.expire)).rel_value_us) { if (0 != UNLINK (filename)) { @@ -143,7 +145,8 @@ get_signkey_file (const char *exchange_directory, char *fn; GNUNET_asprintf (&fn, - "%s" DIR_SEPARATOR_STR TALER_EXCHANGEDB_DIR_SIGNING_KEYS DIR_SEPARATOR_STR "%llu", + "%s" DIR_SEPARATOR_STR TALER_EXCHANGEDB_DIR_SIGNING_KEYS + DIR_SEPARATOR_STR "%llu", exchange_directory, (unsigned long long) start.abs_value_us); return fn; @@ -161,7 +164,9 @@ get_signkey_file (const char *exchange_directory, int TALER_EXCHANGEDB_signing_key_write (const char *exchange_base_dir, struct GNUNET_TIME_Absolute start, - const struct TALER_EXCHANGEDB_PrivateSigningKeyInformationP *ski) + const struct + TALER_EXCHANGEDB_PrivateSigningKeyInformationP + *ski) { char *skf; ssize_t nwrite; @@ -173,8 +178,10 @@ TALER_EXCHANGEDB_signing_key_write (const char *exchange_base_dir, return GNUNET_SYSERR; nwrite = GNUNET_DISK_fn_write (skf, ski, - sizeof (struct TALER_EXCHANGEDB_PrivateSigningKeyInformationP), - GNUNET_DISK_PERM_USER_WRITE | GNUNET_DISK_PERM_USER_READ); + sizeof (struct + TALER_EXCHANGEDB_PrivateSigningKeyInformationP), + GNUNET_DISK_PERM_USER_WRITE + | GNUNET_DISK_PERM_USER_READ); if (sizeof (struct TALER_EXCHANGEDB_PrivateSigningKeyInformationP) != nwrite) { GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, diff --git a/src/exchangedb/perf_taler_exchangedb.c b/src/exchangedb/perf_taler_exchangedb.c index 5cde719c1..64fde0c1d 100644 --- a/src/exchangedb/perf_taler_exchangedb.c +++ b/src/exchangedb/perf_taler_exchangedb.c @@ -50,86 +50,85 @@ * and logs the results using Gauger */ int -main (int argc, char ** argv) +main (int argc, char **argv) { int ret; - struct PERF_TALER_EXCHANGEDB_Cmd benchmark[] = - { + struct PERF_TALER_EXCHANGEDB_Cmd benchmark[] = { /* Denomination used to create coins */ PERF_TALER_EXCHANGEDB_INIT_CMD_DEBUG ("Initializing database"), PERF_TALER_EXCHANGEDB_INIT_CMD_LOOP ("01 - denomination loop", - NB_DENOMINATION_INIT), + NB_DENOMINATION_INIT), PERF_TALER_EXCHANGEDB_INIT_CMD_START_TRANSACTION (""), PERF_TALER_EXCHANGEDB_INIT_CMD_CREATE_DENOMINATION ("01 - denomination"), PERF_TALER_EXCHANGEDB_INIT_CMD_INSERT_DENOMINATION ("01 - insert", - "01 - denomination"), + "01 - denomination"), PERF_TALER_EXCHANGEDB_INIT_CMD_COMMIT_TRANSACTION (""), PERF_TALER_EXCHANGEDB_INIT_CMD_SAVE_ARRAY ("01 - save denomination", - "01 - denomination loop", - "01 - denomination", - NB_DENOMINATION_SAVE), + "01 - denomination loop", + "01 - denomination", + NB_DENOMINATION_SAVE), PERF_TALER_EXCHANGEDB_INIT_CMD_END_LOOP ("01 - end", - "01 - denomination loop"), + "01 - denomination loop"), /* End of initialization */ /* Reserve initialization */ PERF_TALER_EXCHANGEDB_INIT_CMD_LOOP ("02 - init reserve loop", NB_RESERVE_INIT), PERF_TALER_EXCHANGEDB_INIT_CMD_CREATE_RESERVE ("02 - reserve"), PERF_TALER_EXCHANGEDB_INIT_CMD_INSERT_RESERVE ("02 - insert", - "02 - reserve"), + "02 - reserve"), PERF_TALER_EXCHANGEDB_INIT_CMD_SAVE_ARRAY ("02 - save reserve", - "02 - init reserve loop", - "02 - reserve", - NB_RESERVE_SAVE), + "02 - init reserve loop", + "02 - reserve", + NB_RESERVE_SAVE), PERF_TALER_EXCHANGEDB_INIT_CMD_END_LOOP ("02 - end", - "02 - init reserve loop"), + "02 - init reserve loop"), /* End reserve init */ /* Withdrawal initialization */ PERF_TALER_EXCHANGEDB_INIT_CMD_LOOP ("03 - init withdraw loop", - NB_WITHDRAW_INIT), + NB_WITHDRAW_INIT), PERF_TALER_EXCHANGEDB_INIT_CMD_START_TRANSACTION (""), PERF_TALER_EXCHANGEDB_INIT_CMD_LOAD_ARRAY ("03 - denomination load", - "03 - init withdraw loop", - "01 - save denomination"), + "03 - init withdraw loop", + "01 - save denomination"), PERF_TALER_EXCHANGEDB_INIT_CMD_LOAD_ARRAY ("03 - reserve load", - "03 - init withdraw loop", - "02 - save reserve"), + "03 - init withdraw loop", + "02 - save reserve"), PERF_TALER_EXCHANGEDB_INIT_CMD_CREATE_WITHDRAW ("03 - withdraw", - "03 - denomination load", - "03 - reserve load"), + "03 - denomination load", + "03 - reserve load"), PERF_TALER_EXCHANGEDB_INIT_CMD_INSERT_WITHDRAW ("03 - insert", - "03 - withdraw"), + "03 - withdraw"), PERF_TALER_EXCHANGEDB_INIT_CMD_COMMIT_TRANSACTION (""), PERF_TALER_EXCHANGEDB_INIT_CMD_SAVE_ARRAY ("03 - save coin", - "03 - init withdraw loop", - "03 - withdraw", - NB_WITHDRAW_SAVE), + "03 - init withdraw loop", + "03 - withdraw", + NB_WITHDRAW_SAVE), PERF_TALER_EXCHANGEDB_INIT_CMD_END_LOOP ("03 - end", - "03 - init withdraw loop"), + "03 - init withdraw loop"), /*End of withdrawal initialization */ /*Deposit initialization */ PERF_TALER_EXCHANGEDB_INIT_CMD_LOOP ("04 - deposit init loop", - NB_DEPOSIT_INIT), + NB_DEPOSIT_INIT), PERF_TALER_EXCHANGEDB_INIT_CMD_START_TRANSACTION (""), PERF_TALER_EXCHANGEDB_INIT_CMD_LOAD_ARRAY ("04 - coin load", - "04 - deposit init loop", - "03 - save coin"), + "04 - deposit init loop", + "03 - save coin"), PERF_TALER_EXCHANGEDB_INIT_CMD_CREATE_DEPOSIT ("04 - deposit", - "04 - coin load"), + "04 - coin load"), PERF_TALER_EXCHANGEDB_INIT_CMD_INSERT_DEPOSIT ("04 - insert", - "04 - deposit"), + "04 - deposit"), PERF_TALER_EXCHANGEDB_INIT_CMD_COMMIT_TRANSACTION (""), PERF_TALER_EXCHANGEDB_INIT_CMD_SAVE_ARRAY ("04 - deposit array", - "04 - deposit init loop", - "04 - deposit", - NB_DEPOSIT_SAVE), + "04 - deposit init loop", + "04 - deposit", + NB_DEPOSIT_SAVE), PERF_TALER_EXCHANGEDB_INIT_CMD_END_LOOP ("", - "04 - deposit init loop"), + "04 - deposit init loop"), /* End of deposit initialization */ /* Session initialization */ PERF_TALER_EXCHANGEDB_INIT_CMD_LOOP ("05 - refresh session init loop", - NB_REFRESH_INIT), + NB_REFRESH_INIT), PERF_TALER_EXCHANGEDB_INIT_CMD_START_TRANSACTION (""), PERF_TALER_EXCHANGEDB_INIT_CMD_LOAD_ARRAY ("05 - denomination load", "05 - refresh session init loop", @@ -140,8 +139,9 @@ main (int argc, char ** argv) PERF_TALER_EXCHANGEDB_INIT_CMD_CREATE_WITHDRAW ("05 - withdraw", "05 - denomination load", "05 - reserve load"), - PERF_TALER_EXCHANGEDB_INIT_CMD_CREATE_REFRESH_SESSION ("05 - refresh session", - "05 - withdraw"), + PERF_TALER_EXCHANGEDB_INIT_CMD_CREATE_REFRESH_SESSION ( + "05 - refresh session", + "05 - withdraw"), PERF_TALER_EXCHANGEDB_INIT_CMD_SAVE_ARRAY ("05 - session array", "05 - refresh session init loop", "05 - refresh session", @@ -152,190 +152,190 @@ main (int argc, char ** argv) /* End of refresh session initialization */ /* Refresh melt initialization */ PERF_TALER_EXCHANGEDB_INIT_CMD_LOOP ("06 - refresh melt init loop", - NB_MELT_INIT), + NB_MELT_INIT), PERF_TALER_EXCHANGEDB_INIT_CMD_START_TRANSACTION (""), /* TODO: initialize using coins & sessions created localy * in order to make sure the same coin are not melted twice*/ PERF_TALER_EXCHANGEDB_INIT_CMD_LOAD_ARRAY ("06 - session hash", - "06 - refresh melt init loop", - "05 - session array"), + "06 - refresh melt init loop", + "05 - session array"), PERF_TALER_EXCHANGEDB_INIT_CMD_LOAD_ARRAY ("06 - coin", - "06 - refresh melt init loop", - "03 - save coin"), + "06 - refresh melt init loop", + "03 - save coin"), PERF_TALER_EXCHANGEDB_INIT_CMD_COMMIT_TRANSACTION (""), PERF_TALER_EXCHANGEDB_INIT_CMD_END_LOOP ("06 - end", - "06 - refresh melt init loop"), + "06 - refresh melt init loop"), /* End of refresh melt initialization */ PERF_TALER_EXCHANGEDB_INIT_CMD_DEBUG ("End of initialization"), PERF_TALER_EXCHANGEDB_INIT_CMD_DEBUG ("Start of performances measuring"), PERF_TALER_EXCHANGEDB_INIT_CMD_GET_TIME ("21 - start"), PERF_TALER_EXCHANGEDB_INIT_CMD_LOOP ("21 - reserve insert measure", - NB_RESERVE_SAVE), + NB_RESERVE_SAVE), PERF_TALER_EXCHANGEDB_INIT_CMD_CREATE_RESERVE ("21 - reserve"), PERF_TALER_EXCHANGEDB_INIT_CMD_INSERT_RESERVE ("21 - insert", - "21 - reserve"), + "21 - reserve"), PERF_TALER_EXCHANGEDB_INIT_CMD_END_LOOP ("", - "21 - reserve insert measure"), + "21 - reserve insert measure"), PERF_TALER_EXCHANGEDB_INIT_CMD_GET_TIME ("21 - stop"), PERF_TALER_EXCHANGEDB_INIT_CMD_GAUGER ("21 - gauger", - "21 - start", - "21 - stop", - "POSTGRES", - "Number of reserve inserted per second", - "item/sec", - NB_RESERVE_SAVE), + "21 - start", + "21 - stop", + "POSTGRES", + "Number of reserve inserted per second", + "item/sec", + NB_RESERVE_SAVE), PERF_TALER_EXCHANGEDB_INIT_CMD_DEBUG ("End of reserve insertion"), PERF_TALER_EXCHANGEDB_INIT_CMD_GET_TIME ("22 - start"), PERF_TALER_EXCHANGEDB_INIT_CMD_LOOP ("22 - reserve load measure", - NB_RESERVE_SAVE), + NB_RESERVE_SAVE), PERF_TALER_EXCHANGEDB_INIT_CMD_LOAD_ARRAY ("22 - reserve", - "22 - reserve load measure", - "02 - save reserve"), + "22 - reserve load measure", + "02 - save reserve"), PERF_TALER_EXCHANGEDB_INIT_CMD_GET_RESERVE ("22 - get", - "22 - reserve"), + "22 - reserve"), PERF_TALER_EXCHANGEDB_INIT_CMD_END_LOOP ("", - "22 - reserve load measure"), + "22 - reserve load measure"), PERF_TALER_EXCHANGEDB_INIT_CMD_GET_TIME ("22 - stop"), PERF_TALER_EXCHANGEDB_INIT_CMD_GAUGER ("", - "22 - start", - "22 - stop", - "POSTGRES", - "Number of reserve loaded per second", - "item/sec", - NB_RESERVE_SAVE), + "22 - start", + "22 - stop", + "POSTGRES", + "Number of reserve loaded per second", + "item/sec", + NB_RESERVE_SAVE), PERF_TALER_EXCHANGEDB_INIT_CMD_DEBUG ("End of reserve retreival"), PERF_TALER_EXCHANGEDB_INIT_CMD_GET_TIME ("23 - start"), PERF_TALER_EXCHANGEDB_INIT_CMD_LOOP ("23 - reserve history measure", - NB_RESERVE_SAVE), + NB_RESERVE_SAVE), PERF_TALER_EXCHANGEDB_INIT_CMD_LOAD_ARRAY ("23 - reserve", - "23 - reserve history measure", - "02 - save reserve"), + "23 - reserve history measure", + "02 - save reserve"), PERF_TALER_EXCHANGEDB_INIT_CMD_GET_RESERVE_HISTORY ("", - "23 - reserve"), + "23 - reserve"), PERF_TALER_EXCHANGEDB_INIT_CMD_END_LOOP ("", - "23 - reserve history measure"), + "23 - reserve history measure"), PERF_TALER_EXCHANGEDB_INIT_CMD_GET_TIME ("23 - stop"), PERF_TALER_EXCHANGEDB_INIT_CMD_GAUGER ("", - "23 - start", - "23 - stop", - "POSTGRES", - "Number of reserve history loaded per second", - "item/sec", - NB_RESERVE_SAVE), + "23 - start", + "23 - stop", + "POSTGRES", + "Number of reserve history loaded per second", + "item/sec", + NB_RESERVE_SAVE), PERF_TALER_EXCHANGEDB_INIT_CMD_DEBUG ("End of reserve history access"), PERF_TALER_EXCHANGEDB_INIT_CMD_GET_TIME ("24 - start"), PERF_TALER_EXCHANGEDB_INIT_CMD_LOOP ("24 - withdraw insert measure", - NB_WITHDRAW_SAVE), + NB_WITHDRAW_SAVE), PERF_TALER_EXCHANGEDB_INIT_CMD_LOAD_ARRAY ("24 - reserve", - "24 - withdraw insert measure", - "02 - save reserve"), + "24 - withdraw insert measure", + "02 - save reserve"), PERF_TALER_EXCHANGEDB_INIT_CMD_LOAD_ARRAY ("24 - denomination", - "24 - withdraw insert measure", - "01 - save denomination"), + "24 - withdraw insert measure", + "01 - save denomination"), PERF_TALER_EXCHANGEDB_INIT_CMD_CREATE_WITHDRAW ("24 - withdraw", - "24 - denomination", - "24 - reserve"), + "24 - denomination", + "24 - reserve"), PERF_TALER_EXCHANGEDB_INIT_CMD_INSERT_WITHDRAW ("24 - insert", - "24 - withdraw"), + "24 - withdraw"), PERF_TALER_EXCHANGEDB_INIT_CMD_END_LOOP ("", - "24 - withdraw insert measure"), + "24 - withdraw insert measure"), PERF_TALER_EXCHANGEDB_INIT_CMD_GET_TIME ("24 - stop"), PERF_TALER_EXCHANGEDB_INIT_CMD_GAUGER ("", - "24 - start", - "24 - stop", - "POSTGRES", - "Number of withdraw insert per second", - "item/sec", - NB_WITHDRAW_SAVE), + "24 - start", + "24 - stop", + "POSTGRES", + "Number of withdraw insert per second", + "item/sec", + NB_WITHDRAW_SAVE), PERF_TALER_EXCHANGEDB_INIT_CMD_DEBUG ("End of withdraw insertion"), PERF_TALER_EXCHANGEDB_INIT_CMD_GET_TIME ("25 - start"), PERF_TALER_EXCHANGEDB_INIT_CMD_LOOP ("25 - withdraw insert measure", - NB_RESERVE_SAVE), + NB_RESERVE_SAVE), PERF_TALER_EXCHANGEDB_INIT_CMD_LOAD_ARRAY ("25 - coin", - "25 - withdraw insert measure", - "03 - save coin"), + "25 - withdraw insert measure", + "03 - save coin"), PERF_TALER_EXCHANGEDB_INIT_CMD_GET_WITHDRAW ("", - "25 - coin"), + "25 - coin"), PERF_TALER_EXCHANGEDB_INIT_CMD_END_LOOP ("", - "25 - withdraw insert measure"), + "25 - withdraw insert measure"), PERF_TALER_EXCHANGEDB_INIT_CMD_GET_TIME ("25 - stop"), PERF_TALER_EXCHANGEDB_INIT_CMD_GAUGER ("", - "25 - start", - "25 - stop", - "POSTGRES", - "Number of withdraw loaded per second", - "item/sec", - NB_RESERVE_SAVE), + "25 - start", + "25 - stop", + "POSTGRES", + "Number of withdraw loaded per second", + "item/sec", + NB_RESERVE_SAVE), PERF_TALER_EXCHANGEDB_INIT_CMD_DEBUG ("End of withdraw loading"), PERF_TALER_EXCHANGEDB_INIT_CMD_GET_TIME ("26 - start"), PERF_TALER_EXCHANGEDB_INIT_CMD_LOOP ("26 - get coin transaction", - NB_WITHDRAW_SAVE), + NB_WITHDRAW_SAVE), PERF_TALER_EXCHANGEDB_INIT_CMD_LOAD_ARRAY ("26 - coin", - "26 - get coin transaction", - "03 - save coin"), - PERF_TALER_EXCHANGEDB_INIT_CMD_GET_COIN_TRANSACTION("", - "26 - coin"), + "26 - get coin transaction", + "03 - save coin"), + PERF_TALER_EXCHANGEDB_INIT_CMD_GET_COIN_TRANSACTION ("", + "26 - coin"), PERF_TALER_EXCHANGEDB_INIT_CMD_END_LOOP ("", - "26 - get coin transaction"), + "26 - get coin transaction"), PERF_TALER_EXCHANGEDB_INIT_CMD_GET_TIME ("26 - end"), PERF_TALER_EXCHANGEDB_INIT_CMD_GAUGER ("", - "26 - start", - "26 - end", - "POSTGRES", - "Number of coin transaction history loaded per second", - "item/sec", - NB_WITHDRAW_SAVE), + "26 - start", + "26 - end", + "POSTGRES", + "Number of coin transaction history loaded per second", + "item/sec", + NB_WITHDRAW_SAVE), PERF_TALER_EXCHANGEDB_INIT_CMD_DEBUG ("End of transaction loading"), PERF_TALER_EXCHANGEDB_INIT_CMD_GET_TIME ("27 - start"), PERF_TALER_EXCHANGEDB_INIT_CMD_LOOP ("27 - /reserve/withdraw", - NB_WITHDRAW_SAVE), + NB_WITHDRAW_SAVE), PERF_TALER_EXCHANGEDB_INIT_CMD_LOAD_ARRAY ("27 - reserve", - "27 - /reserve/withdraw", - "02 - save reserve"), + "27 - /reserve/withdraw", + "02 - save reserve"), PERF_TALER_EXCHANGEDB_INIT_CMD_LOAD_ARRAY ("27 - dki", - "27 - /reserve/withdraw", - "01 - save denomination"), + "27 - /reserve/withdraw", + "01 - save denomination"), PERF_TALER_EXCHANGEDB_INIT_CMD_WITHDRAW_SIGN ("", - "27 - dki", - "27 - reserve"), + "27 - dki", + "27 - reserve"), PERF_TALER_EXCHANGEDB_INIT_CMD_END_LOOP ("", - "27 - /reserve/withdraw"), + "27 - /reserve/withdraw"), PERF_TALER_EXCHANGEDB_INIT_CMD_GET_TIME ("27 - end"), PERF_TALER_EXCHANGEDB_INIT_CMD_GAUGER ("", - "27 - start", - "27 - end", - "POSTGRES", - "Number of /reserve/withdraw per second", - "item/sec", - NB_WITHDRAW_SAVE), + "27 - start", + "27 - end", + "POSTGRES", + "Number of /reserve/withdraw per second", + "item/sec", + NB_WITHDRAW_SAVE), PERF_TALER_EXCHANGEDB_INIT_CMD_DEBUG ("End of /reserve/withdraw"), PERF_TALER_EXCHANGEDB_INIT_CMD_GET_TIME ("28 - start"), PERF_TALER_EXCHANGEDB_INIT_CMD_LOOP ("28 - /deposit", - NB_DEPOSIT_SAVE), + NB_DEPOSIT_SAVE), PERF_TALER_EXCHANGEDB_INIT_CMD_LOAD_ARRAY ("28 - coin", - "28 - /deposit", - "03 - save coin"), + "28 - /deposit", + "03 - save coin"), PERF_TALER_EXCHANGEDB_INIT_CMD_DEPOSIT ("28 - deposit", - "28 - coin"), + "28 - coin"), PERF_TALER_EXCHANGEDB_INIT_CMD_END_LOOP ("", - "28 - /deposit"), + "28 - /deposit"), PERF_TALER_EXCHANGEDB_INIT_CMD_GET_TIME ("28 - stop"), PERF_TALER_EXCHANGEDB_INIT_CMD_GAUGER ("", - "28 - start", - "28 - stop", - "POSTGRES", - "Number of /deposit per second", - "item/sec", - NB_DEPOSIT_SAVE), + "28 - start", + "28 - stop", + "POSTGRES", + "Number of /deposit per second", + "item/sec", + NB_DEPOSIT_SAVE), PERF_TALER_EXCHANGEDB_INIT_CMD_GET_TIME ("29 - start"), PERF_TALER_EXCHANGEDB_INIT_CMD_LOOP ("29 - insert refresh session", NB_REFRESH_SAVE), @@ -349,30 +349,32 @@ main (int argc, char ** argv) PERF_TALER_EXCHANGEDB_INIT_CMD_CREATE_WITHDRAW ("29 - withdraw", "29 - denomination load", "29 - reserve load"), - PERF_TALER_EXCHANGEDB_INIT_CMD_CREATE_REFRESH_SESSION ("29 - refresh session", - "29 - withdraw"), + PERF_TALER_EXCHANGEDB_INIT_CMD_CREATE_REFRESH_SESSION ( + "29 - refresh session", + "29 - withdraw"), PERF_TALER_EXCHANGEDB_INIT_CMD_SAVE_ARRAY ("29 - session array", "29 - insert refresh session", "29 - refresh session", NB_RESERVE_SAVE), PERF_TALER_EXCHANGEDB_INIT_CMD_COMMIT_TRANSACTION (""), PERF_TALER_EXCHANGEDB_INIT_CMD_END_LOOP ("", - "29 - insert refresh session"), + "29 - insert refresh session"), PERF_TALER_EXCHANGEDB_INIT_CMD_GET_TIME ("29 - stop"), PERF_TALER_EXCHANGEDB_INIT_CMD_GAUGER ("", - "29 - start", - "29 - stop", - "POSTGRES", - "Number of refresh session inserted per second", - "item/sec", - NB_REFRESH_SAVE), + "29 - start", + "29 - stop", + "POSTGRES", + "Number of refresh session inserted per second", + "item/sec", + NB_REFRESH_SAVE), PERF_TALER_EXCHANGEDB_INIT_CMD_END (""), }; ret = PERF_TALER_EXCHANGEDB_run_benchmark ( "perf-taler-exchangedb", "./test-exchange-db-postgres.conf", - (struct PERF_TALER_EXCHANGEDB_Cmd []) {PERF_TALER_EXCHANGEDB_INIT_CMD_END("")}, + (struct PERF_TALER_EXCHANGEDB_Cmd []) {PERF_TALER_EXCHANGEDB_INIT_CMD_END ( + "")}, benchmark); if (GNUNET_SYSERR == ret) return 1; diff --git a/src/exchangedb/perf_taler_exchangedb_init.c b/src/exchangedb/perf_taler_exchangedb_init.c index 7053bca48..d27634bd8 100644 --- a/src/exchangedb/perf_taler_exchangedb_init.c +++ b/src/exchangedb/perf_taler_exchangedb_init.c @@ -43,7 +43,7 @@ PERF_TALER_EXCHANGEDB_denomination_init () struct TALER_DenominationPublicKey denom_pub; struct TALER_EXCHANGEDB_DenominationKeyInformationP issue; - master_prvt = GNUNET_CRYPTO_eddsa_key_create(); + master_prvt = GNUNET_CRYPTO_eddsa_key_create (); dki = GNUNET_new (struct TALER_EXCHANGEDB_DenominationKeyIssueInformation); GNUNET_assert (NULL != dki); @@ -61,16 +61,21 @@ PERF_TALER_EXCHANGEDB_denomination_init () struct TALER_Amount amount; struct GNUNET_TIME_Absolute now; - properties.purpose.purpose = htonl (TALER_SIGNATURE_MASTER_SIGNING_KEY_VALIDITY); - properties.purpose.size = htonl (sizeof (struct TALER_DenominationKeyValidityPS)); + properties.purpose.purpose = htonl ( + TALER_SIGNATURE_MASTER_SIGNING_KEY_VALIDITY); + properties.purpose.size = htonl (sizeof (struct + TALER_DenominationKeyValidityPS)); GNUNET_CRYPTO_eddsa_key_get_public (master_prvt, &properties.master.eddsa_pub); - now = GNUNET_TIME_absolute_get(); + now = GNUNET_TIME_absolute_get (); (void) GNUNET_TIME_round_abs (&now); properties.start = GNUNET_TIME_absolute_hton (now); - properties.expire_withdraw = GNUNET_TIME_absolute_hton (GNUNET_TIME_UNIT_FOREVER_ABS); - properties.expire_deposit = GNUNET_TIME_absolute_hton (GNUNET_TIME_UNIT_FOREVER_ABS); - properties.expire_legal = GNUNET_TIME_absolute_hton (GNUNET_TIME_UNIT_FOREVER_ABS); + properties.expire_withdraw = GNUNET_TIME_absolute_hton ( + GNUNET_TIME_UNIT_FOREVER_ABS); + properties.expire_deposit = GNUNET_TIME_absolute_hton ( + GNUNET_TIME_UNIT_FOREVER_ABS); + properties.expire_legal = GNUNET_TIME_absolute_hton ( + GNUNET_TIME_UNIT_FOREVER_ABS); GNUNET_assert (GNUNET_OK == TALER_string_to_amount (CURRENCY ":1.1", &amount)); TALER_amount_hton (&properties.value, &amount); @@ -105,15 +110,18 @@ PERF_TALER_EXCHANGEDB_denomination_init () * @return a copy of @a deposit; NULL if error */ struct TALER_EXCHANGEDB_DenominationKeyIssueInformation * -PERF_TALER_EXCHANGEDB_denomination_copy (const struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *dki) +PERF_TALER_EXCHANGEDB_denomination_copy (const struct + TALER_EXCHANGEDB_DenominationKeyIssueInformation + *dki) { struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *copy; GNUNET_assert (NULL != - (copy = GNUNET_new (struct TALER_EXCHANGEDB_DenominationKeyIssueInformation))); + (copy = GNUNET_new (struct + TALER_EXCHANGEDB_DenominationKeyIssueInformation))); {/* denom_priv */ copy->denom_priv.rsa_private_key = - GNUNET_CRYPTO_rsa_private_key_dup ( dki->denom_priv.rsa_private_key); + GNUNET_CRYPTO_rsa_private_key_dup (dki->denom_priv.rsa_private_key); } {/* denom_pub */ copy->denom_pub.rsa_public_key = @@ -132,7 +140,9 @@ PERF_TALER_EXCHANGEDB_denomination_copy (const struct TALER_EXCHANGEDB_Denominat * @param dki pointer to the struct to free */ int -PERF_TALER_EXCHANGEDB_denomination_free (struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *dki) +PERF_TALER_EXCHANGEDB_denomination_free (struct + TALER_EXCHANGEDB_DenominationKeyIssueInformation + *dki) { if (NULL == dki) return GNUNET_OK; @@ -166,7 +176,8 @@ PERF_TALER_EXCHANGEDB_reserve_init () GNUNET_CRYPTO_eddsa_key_get_public (&reserve->private, &reserve->reserve.pub.eddsa_pub); GNUNET_assert (GNUNET_OK == - TALER_string_to_amount (CURRENCY ":1000", &reserve->reserve.balance)); + TALER_string_to_amount (CURRENCY ":1000", + &reserve->reserve.balance)); reserve->reserve.expiry = GNUNET_TIME_UNIT_FOREVER_ABS; return reserve; } @@ -178,7 +189,8 @@ PERF_TALER_EXCHANGEDB_reserve_init () * @return a copy of @a reserve; NULL if error */ struct PERF_TALER_EXCHANGEDB_Reserve * -PERF_TALER_EXCHANGEDB_reserve_copy (const struct PERF_TALER_EXCHANGEDB_Reserve *reserve) +PERF_TALER_EXCHANGEDB_reserve_copy (const struct + PERF_TALER_EXCHANGEDB_Reserve *reserve) { struct PERF_TALER_EXCHANGEDB_Reserve *copy; GNUNET_assert (NULL != @@ -193,7 +205,8 @@ PERF_TALER_EXCHANGEDB_reserve_copy (const struct PERF_TALER_EXCHANGEDB_Reserve * * @param reserve pointer to the structure to be freed */ int -PERF_TALER_EXCHANGEDB_reserve_free (struct PERF_TALER_EXCHANGEDB_Reserve *reserve) +PERF_TALER_EXCHANGEDB_reserve_free (struct + PERF_TALER_EXCHANGEDB_Reserve *reserve) { if (NULL == reserve) return GNUNET_OK; @@ -208,7 +221,8 @@ PERF_TALER_EXCHANGEDB_reserve_free (struct PERF_TALER_EXCHANGEDB_Reserve *reserv * @param dki the denomination key used to sign the key */ struct TALER_EXCHANGEDB_Deposit * -PERF_TALER_EXCHANGEDB_deposit_init (const struct PERF_TALER_EXCHANGEDB_Coin *coin) +PERF_TALER_EXCHANGEDB_deposit_init (const struct + PERF_TALER_EXCHANGEDB_Coin *coin) { struct TALER_EXCHANGEDB_Deposit *deposit; struct TALER_CoinSpendSignatureP csig; @@ -225,7 +239,7 @@ PERF_TALER_EXCHANGEDB_deposit_init (const struct PERF_TALER_EXCHANGEDB_Coin *coi &h_contract_terms); GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_WEAK, &h_wire); - { //csig + { // csig struct u32_presign { struct GNUNET_CRYPTO_EccSignaturePurpose purpose; @@ -242,11 +256,11 @@ PERF_TALER_EXCHANGEDB_deposit_init (const struct PERF_TALER_EXCHANGEDB_Coin *coi &unsigned_data.purpose, &csig.eddsa_signature)); } - { //merchant_pub + { // merchant_pub struct GNUNET_CRYPTO_EddsaPrivateKey *eddsa_prv; eddsa_prv = GNUNET_CRYPTO_eddsa_key_create (); - GNUNET_assert(NULL != eddsa_prv); + GNUNET_assert (NULL != eddsa_prv); GNUNET_CRYPTO_eddsa_key_get_public (eddsa_prv, &merchant_pub.eddsa_pub); GNUNET_free (eddsa_prv); @@ -289,7 +303,8 @@ PERF_TALER_EXCHANGEDB_deposit_init (const struct PERF_TALER_EXCHANGEDB_Coin *coi * @return a copy of @a deposit; NULL if error */ struct TALER_EXCHANGEDB_Deposit * -PERF_TALER_EXCHANGEDB_deposit_copy (const struct TALER_EXCHANGEDB_Deposit *deposit) +PERF_TALER_EXCHANGEDB_deposit_copy (const struct + TALER_EXCHANGEDB_Deposit *deposit) { struct TALER_EXCHANGEDB_Deposit *copy; @@ -337,7 +352,7 @@ PERF_TALER_EXCHANGEDB_coin_init ( GNUNET_assert (NULL != coin); /* priv */ - priv = GNUNET_CRYPTO_eddsa_key_create(); + priv = GNUNET_CRYPTO_eddsa_key_create (); GNUNET_assert (NULL != priv); coin->priv = *priv; GNUNET_free (priv); @@ -480,14 +495,16 @@ PERF_TALER_EXCHANGEDB_refresh_melt_init (struct TALER_RefreshCommitmentP *rc, * @return an copy of @ melt */ struct TALER_EXCHANGEDB_RefreshMelt * -PERF_TALER_EXCHANGEDB_refresh_melt_copy (const struct TALER_EXCHANGEDB_RefreshMelt *melt) +PERF_TALER_EXCHANGEDB_refresh_melt_copy (const struct + TALER_EXCHANGEDB_RefreshMelt *melt) { struct TALER_EXCHANGEDB_RefreshMelt *copy; copy = GNUNET_new (struct TALER_EXCHANGEDB_RefreshMelt); *copy = *melt; copy->session.coin.denom_sig.rsa_signature = - GNUNET_CRYPTO_rsa_signature_dup (melt->session.coin.denom_sig.rsa_signature); + GNUNET_CRYPTO_rsa_signature_dup ( + melt->session.coin.denom_sig.rsa_signature); GNUNET_assert (NULL != copy->session.coin.denom_sig.rsa_signature); return copy; @@ -501,7 +518,8 @@ PERF_TALER_EXCHANGEDB_refresh_melt_copy (const struct TALER_EXCHANGEDB_RefreshMe * @return #GNUNET_OK if the operation was successful, #GNUNET_SYSERROR */ int -PERF_TALER_EXCHANGEDB_refresh_melt_free (struct TALER_EXCHANGEDB_RefreshMelt *melt) +PERF_TALER_EXCHANGEDB_refresh_melt_free (struct + TALER_EXCHANGEDB_RefreshMelt *melt) { GNUNET_CRYPTO_rsa_signature_free (melt->session.coin.denom_sig.rsa_signature); GNUNET_free (melt); diff --git a/src/exchangedb/perf_taler_exchangedb_init.h b/src/exchangedb/perf_taler_exchangedb_init.h index a1f2559e2..f20b35c5b 100644 --- a/src/exchangedb/perf_taler_exchangedb_init.h +++ b/src/exchangedb/perf_taler_exchangedb_init.h @@ -79,7 +79,9 @@ PERF_TALER_EXCHANGEDB_denomination_init (void); * @return a copy of @a deposit; NULL if error */ struct TALER_EXCHANGEDB_DenominationKeyIssueInformation * -PERF_TALER_EXCHANGEDB_denomination_copy (const struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *dki); +PERF_TALER_EXCHANGEDB_denomination_copy (const struct + TALER_EXCHANGEDB_DenominationKeyIssueInformation + *dki); /** @@ -87,7 +89,9 @@ PERF_TALER_EXCHANGEDB_denomination_copy (const struct TALER_EXCHANGEDB_Denominat * @param dki pointer to the struct to free */ int -PERF_TALER_EXCHANGEDB_denomination_free (struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *dki); +PERF_TALER_EXCHANGEDB_denomination_free (struct + TALER_EXCHANGEDB_DenominationKeyIssueInformation + *dki); /** @@ -104,7 +108,8 @@ PERF_TALER_EXCHANGEDB_reserve_init (void); * @return a copy of @a reserve; NULL if error */ struct PERF_TALER_EXCHANGEDB_Reserve * -PERF_TALER_EXCHANGEDB_reserve_copy (const struct PERF_TALER_EXCHANGEDB_Reserve *reserve); +PERF_TALER_EXCHANGEDB_reserve_copy (const struct + PERF_TALER_EXCHANGEDB_Reserve *reserve); /** @@ -112,7 +117,8 @@ PERF_TALER_EXCHANGEDB_reserve_copy (const struct PERF_TALER_EXCHANGEDB_Reserve * * @param reserve pointer to the structure to be freed */ int -PERF_TALER_EXCHANGEDB_reserve_free (struct PERF_TALER_EXCHANGEDB_Reserve *reserve); +PERF_TALER_EXCHANGEDB_reserve_free (struct + PERF_TALER_EXCHANGEDB_Reserve *reserve); /** @@ -120,7 +126,8 @@ PERF_TALER_EXCHANGEDB_reserve_free (struct PERF_TALER_EXCHANGEDB_Reserve *reserv * @param dki the denomination key used to sign the key */ struct TALER_EXCHANGEDB_Deposit * -PERF_TALER_EXCHANGEDB_deposit_init (const struct PERF_TALER_EXCHANGEDB_Coin *coin); +PERF_TALER_EXCHANGEDB_deposit_init (const struct + PERF_TALER_EXCHANGEDB_Coin *coin); /** @@ -129,7 +136,8 @@ PERF_TALER_EXCHANGEDB_deposit_init (const struct PERF_TALER_EXCHANGEDB_Coin *coi * @return a copy of @a deposit; NULL if error */ struct TALER_EXCHANGEDB_Deposit * -PERF_TALER_EXCHANGEDB_deposit_copy (const struct TALER_EXCHANGEDB_Deposit *deposit); +PERF_TALER_EXCHANGEDB_deposit_copy (const struct + TALER_EXCHANGEDB_Deposit *deposit); /** @@ -147,8 +155,11 @@ PERF_TALER_EXCHANGEDB_deposit_free (struct TALER_EXCHANGEDB_Deposit *deposit); * @return a randomly generated CollectableBlindcoin */ struct PERF_TALER_EXCHANGEDB_Coin * -PERF_TALER_EXCHANGEDB_coin_init (const struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *dki, - const struct PERF_TALER_EXCHANGEDB_Reserve *reserve); +PERF_TALER_EXCHANGEDB_coin_init (const struct + TALER_EXCHANGEDB_DenominationKeyIssueInformation + *dki, + const struct + PERF_TALER_EXCHANGEDB_Reserve *reserve); /** @@ -187,7 +198,8 @@ PERF_TALER_EXCHANGEDB_refresh_melt_init (struct TALER_RefreshCommitmentP *rc, * @return an copy of @ melt */ struct TALER_EXCHANGEDB_RefreshMelt * -PERF_TALER_EXCHANGEDB_refresh_melt_copy (const struct TALER_EXCHANGEDB_RefreshMelt *melt); +PERF_TALER_EXCHANGEDB_refresh_melt_copy (const struct + TALER_EXCHANGEDB_RefreshMelt *melt); /** @@ -197,6 +209,7 @@ PERF_TALER_EXCHANGEDB_refresh_melt_copy (const struct TALER_EXCHANGEDB_RefreshMe * @return #GNUNET_OK if the operation was successful, #GNUNET_SYSERROR */ int -PERF_TALER_EXCHANGEDB_refresh_melt_free (struct TALER_EXCHANGEDB_RefreshMelt *melt); +PERF_TALER_EXCHANGEDB_refresh_melt_free (struct + TALER_EXCHANGEDB_RefreshMelt *melt); #endif diff --git a/src/exchangedb/perf_taler_exchangedb_interpreter.c b/src/exchangedb/perf_taler_exchangedb_interpreter.c index 6c968410b..8286966c2 100644 --- a/src/exchangedb/perf_taler_exchangedb_interpreter.c +++ b/src/exchangedb/perf_taler_exchangedb_interpreter.c @@ -110,31 +110,31 @@ data_copy (const struct PERF_TALER_EXCHANGEDB_Data *data, copy->type = data->type; switch (data->type) { - case PERF_TALER_EXCHANGEDB_TIME: - copy->data.time = GNUNET_new (struct GNUNET_TIME_Absolute); - *copy->data.time = *data->data.time; - return; - case PERF_TALER_EXCHANGEDB_DEPOSIT: - copy->data.deposit - = PERF_TALER_EXCHANGEDB_deposit_copy (data->data.deposit); - return; - case PERF_TALER_EXCHANGEDB_COIN: - copy->data.coin - = PERF_TALER_EXCHANGEDB_coin_copy (data->data.coin); - return; - case PERF_TALER_EXCHANGEDB_RESERVE: - copy->data.reserve - = PERF_TALER_EXCHANGEDB_reserve_copy (data->data.reserve); - return; - case PERF_TALER_EXCHANGEDB_DENOMINATION_INFO: - copy->data.dki - = PERF_TALER_EXCHANGEDB_denomination_copy (data->data.dki); - return; - case PERF_TALER_EXCHANGEDB_REFRESH_HASH: - copy->data.rc = data->data.rc; - break; - case PERF_TALER_EXCHANGEDB_NONE: - break; + case PERF_TALER_EXCHANGEDB_TIME: + copy->data.time = GNUNET_new (struct GNUNET_TIME_Absolute); + *copy->data.time = *data->data.time; + return; + case PERF_TALER_EXCHANGEDB_DEPOSIT: + copy->data.deposit + = PERF_TALER_EXCHANGEDB_deposit_copy (data->data.deposit); + return; + case PERF_TALER_EXCHANGEDB_COIN: + copy->data.coin + = PERF_TALER_EXCHANGEDB_coin_copy (data->data.coin); + return; + case PERF_TALER_EXCHANGEDB_RESERVE: + copy->data.reserve + = PERF_TALER_EXCHANGEDB_reserve_copy (data->data.reserve); + return; + case PERF_TALER_EXCHANGEDB_DENOMINATION_INFO: + copy->data.dki + = PERF_TALER_EXCHANGEDB_denomination_copy (data->data.dki); + return; + case PERF_TALER_EXCHANGEDB_REFRESH_HASH: + copy->data.rc = data->data.rc; + break; + case PERF_TALER_EXCHANGEDB_NONE: + break; } } @@ -151,7 +151,7 @@ cmd_find (const struct PERF_TALER_EXCHANGEDB_Cmd *cmd, { unsigned int i; - for (i=0; PERF_TALER_EXCHANGEDB_CMD_END != cmd[i].command; i++) + for (i = 0; PERF_TALER_EXCHANGEDB_CMD_END != cmd[i].command; i++) if (0 == strcmp (cmd[i].label, search)) return i; return GNUNET_SYSERR; @@ -171,718 +171,721 @@ cmd_init (struct PERF_TALER_EXCHANGEDB_Cmd cmd[]) { unsigned int i; - for (i=0; PERF_TALER_EXCHANGEDB_CMD_END != cmd[i].command; i++) + for (i = 0; PERF_TALER_EXCHANGEDB_CMD_END != cmd[i].command; i++) { switch (cmd[i].command) { - case PERF_TALER_EXCHANGEDB_CMD_END_LOOP: - { - int ret; + case PERF_TALER_EXCHANGEDB_CMD_END_LOOP: + { + int ret; - ret = cmd_find (cmd, - cmd[i].details.end_loop.label_loop); - if (GNUNET_SYSERR == ret) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "%d:Undefined reference to %s\n", - i, + ret = cmd_find (cmd, cmd[i].details.end_loop.label_loop); - return GNUNET_SYSERR; - } - if (PERF_TALER_EXCHANGEDB_CMD_LOOP != cmd[ret].command) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "%d:Wrong type reference to %s at %s\n", - i, - cmd[i].details.end_loop.label_loop, - cmd[i].label); - return GNUNET_SYSERR; - } - cmd[i].details.end_loop.index_loop = ret; + if (GNUNET_SYSERR == ret) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "%d:Undefined reference to %s\n", + i, + cmd[i].details.end_loop.label_loop); + return GNUNET_SYSERR; } - break; - - case PERF_TALER_EXCHANGEDB_CMD_SAVE_ARRAY: + if (PERF_TALER_EXCHANGEDB_CMD_LOOP != cmd[ret].command) { - int ret; + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "%d:Wrong type reference to %s at %s\n", + i, + cmd[i].details.end_loop.label_loop, + cmd[i].label); + return GNUNET_SYSERR; + } + cmd[i].details.end_loop.index_loop = ret; + } + break; - ret = cmd_find (cmd, - cmd[i].details.save_array.label_save); - if (GNUNET_SYSERR == ret) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "%d:Undefined reference to %s at %s\n", - i, - cmd[i].details.save_array.label_save, - cmd[i].label); - return GNUNET_SYSERR; - } - if (PERF_TALER_EXCHANGEDB_NONE == cmd[ret].exposed.type) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "%d:Wrong type reference to %s at %s\n", - i, - cmd[i].details.save_array.label_save, - cmd[i].label); - return GNUNET_SYSERR; - } - cmd[i].details.save_array.index_save = ret; + case PERF_TALER_EXCHANGEDB_CMD_SAVE_ARRAY: + { + int ret; - ret = cmd_find (cmd, - cmd[i].details.save_array.label_loop); - if (GNUNET_SYSERR == ret) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "%d:Undefined reference to %s at %s\n", - i, - cmd[i].details.save_array.label_loop, - cmd[i].label); - return GNUNET_SYSERR; - } - if (PERF_TALER_EXCHANGEDB_CMD_LOOP != cmd[ret].command) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "%d:Wrong type reference to %s at %s\n", - i, - cmd[i].details.save_array.label_loop, - cmd[i].label); - return GNUNET_SYSERR; - } - cmd[i].details.save_array.index_loop = ret; - - GNUNET_assert (NULL == cmd[i].details.save_array.data_saved); - cmd[i].details.save_array.data_saved = - GNUNET_new_array (cmd[i].details.save_array.nb_saved, - struct PERF_TALER_EXCHANGEDB_Data); - cmd[i].details.save_array.type_saved = - cmd[cmd[i].details.save_array.index_save].exposed.type; + ret = cmd_find (cmd, + cmd[i].details.save_array.label_save); + if (GNUNET_SYSERR == ret) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "%d:Undefined reference to %s at %s\n", + i, + cmd[i].details.save_array.label_save, + cmd[i].label); + return GNUNET_SYSERR; } - break; - - case PERF_TALER_EXCHANGEDB_CMD_LOAD_ARRAY: + if (PERF_TALER_EXCHANGEDB_NONE == cmd[ret].exposed.type) { - int ret; - - ret = cmd_find (cmd, - cmd[i].details.load_array.label_save); - if (GNUNET_SYSERR == ret) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "%d:Undefined reference to %s at %s\n", - i, - cmd[i].details.load_array.label_save, - cmd[i].label); - return GNUNET_SYSERR; - } - if (PERF_TALER_EXCHANGEDB_CMD_SAVE_ARRAY != cmd[ret].command) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "%d:Wrong type reference to %s at %s\n", - i, - cmd[i].details.load_array.label_save, - cmd[i].label); - return GNUNET_SYSERR; - } - cmd[i].details.load_array.index_save = ret; + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "%d:Wrong type reference to %s at %s\n", + i, + cmd[i].details.save_array.label_save, + cmd[i].label); + return GNUNET_SYSERR; + } + cmd[i].details.save_array.index_save = ret; - ret = cmd_find (cmd, - cmd[i].details.load_array.label_loop); - if (GNUNET_SYSERR == ret) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "%d:Undefined reference to %s\n", - i, - cmd[i].details.load_array.label_loop); - return GNUNET_SYSERR; - } - if (PERF_TALER_EXCHANGEDB_CMD_LOOP != cmd[ret].command) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "%d:Wrong type reference to %s\n", - i, - cmd[i].details.load_array.label_loop); - return GNUNET_SYSERR; - } - cmd[i].details.load_array.index_loop = ret; + ret = cmd_find (cmd, + cmd[i].details.save_array.label_loop); + if (GNUNET_SYSERR == ret) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "%d:Undefined reference to %s at %s\n", + i, + cmd[i].details.save_array.label_loop, + cmd[i].label); + return GNUNET_SYSERR; + } + if (PERF_TALER_EXCHANGEDB_CMD_LOOP != cmd[ret].command) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "%d:Wrong type reference to %s at %s\n", + i, + cmd[i].details.save_array.label_loop, + cmd[i].label); + return GNUNET_SYSERR; + } + cmd[i].details.save_array.index_loop = ret; + + GNUNET_assert (NULL == cmd[i].details.save_array.data_saved); + cmd[i].details.save_array.data_saved = + GNUNET_new_array (cmd[i].details.save_array.nb_saved, + struct PERF_TALER_EXCHANGEDB_Data); + cmd[i].details.save_array.type_saved = + cmd[cmd[i].details.save_array.index_save].exposed.type; + } + break; - cmd[i].details.load_array.permutation = - GNUNET_CRYPTO_random_permute ( - GNUNET_CRYPTO_QUALITY_WEAK, - cmd[cmd[i].details.load_array.index_save].details.save_array.nb_saved); - GNUNET_assert (NULL != cmd[i].details.load_array.permutation); + case PERF_TALER_EXCHANGEDB_CMD_LOAD_ARRAY: + { + int ret; - cmd[i].exposed.type = cmd[cmd[i].details.load_array.index_save].details.save_array.type_saved; + ret = cmd_find (cmd, + cmd[i].details.load_array.label_save); + if (GNUNET_SYSERR == ret) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "%d:Undefined reference to %s at %s\n", + i, + cmd[i].details.load_array.label_save, + cmd[i].label); + return GNUNET_SYSERR; + } + if (PERF_TALER_EXCHANGEDB_CMD_SAVE_ARRAY != cmd[ret].command) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "%d:Wrong type reference to %s at %s\n", + i, + cmd[i].details.load_array.label_save, + cmd[i].label); + return GNUNET_SYSERR; } - break; + cmd[i].details.load_array.index_save = ret; - case PERF_TALER_EXCHANGEDB_CMD_LOAD_RANDOM: + ret = cmd_find (cmd, + cmd[i].details.load_array.label_loop); + if (GNUNET_SYSERR == ret) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "%d:Undefined reference to %s\n", + i, + cmd[i].details.load_array.label_loop); + return GNUNET_SYSERR; + } + if (PERF_TALER_EXCHANGEDB_CMD_LOOP != cmd[ret].command) { - int ret; + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "%d:Wrong type reference to %s\n", + i, + cmd[i].details.load_array.label_loop); + return GNUNET_SYSERR; + } + cmd[i].details.load_array.index_loop = ret; + + cmd[i].details.load_array.permutation = + GNUNET_CRYPTO_random_permute ( + GNUNET_CRYPTO_QUALITY_WEAK, + cmd[cmd[i].details.load_array.index_save].details.save_array. + nb_saved); + GNUNET_assert (NULL != cmd[i].details.load_array.permutation); + + cmd[i].exposed.type = + cmd[cmd[i].details.load_array.index_save].details.save_array. + type_saved; + } + break; - ret = cmd_find (cmd, - cmd[i].details.load_random.label_save); - if (GNUNET_SYSERR == ret) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "%d:Undefined reference to %s\n", - i, - cmd[i].details.load_random.label_save); - return GNUNET_SYSERR; - } - if (PERF_TALER_EXCHANGEDB_CMD_SAVE_ARRAY != cmd[ret].command) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "%d:Wrong type reference to %s\n", - i, + case PERF_TALER_EXCHANGEDB_CMD_LOAD_RANDOM: + { + int ret; + + ret = cmd_find (cmd, cmd[i].details.load_random.label_save); - return GNUNET_SYSERR; - } - cmd[i].details.load_random.index_save = ret; + if (GNUNET_SYSERR == ret) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "%d:Undefined reference to %s\n", + i, + cmd[i].details.load_random.label_save); + return GNUNET_SYSERR; } - break; - - case PERF_TALER_EXCHANGEDB_CMD_GAUGER: + if (PERF_TALER_EXCHANGEDB_CMD_SAVE_ARRAY != cmd[ret].command) { - int ret; + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "%d:Wrong type reference to %s\n", + i, + cmd[i].details.load_random.label_save); + return GNUNET_SYSERR; + } + cmd[i].details.load_random.index_save = ret; + } + break; - ret = cmd_find (cmd, - cmd[i].details.gauger.label_start); - if (GNUNET_SYSERR == ret) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "%d:Undefined reference to %s\n", - i, - cmd[i].details.gauger.label_start); - return GNUNET_SYSERR; - } - if (PERF_TALER_EXCHANGEDB_TIME != cmd[ret].exposed.type) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "%d:Wrong type reference to %s\n", - i, + case PERF_TALER_EXCHANGEDB_CMD_GAUGER: + { + int ret; + + ret = cmd_find (cmd, cmd[i].details.gauger.label_start); - return GNUNET_SYSERR; - } - cmd[i].details.gauger.index_start = ret; + if (GNUNET_SYSERR == ret) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "%d:Undefined reference to %s\n", + i, + cmd[i].details.gauger.label_start); + return GNUNET_SYSERR; + } + if (PERF_TALER_EXCHANGEDB_TIME != cmd[ret].exposed.type) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "%d:Wrong type reference to %s\n", + i, + cmd[i].details.gauger.label_start); + return GNUNET_SYSERR; + } + cmd[i].details.gauger.index_start = ret; - ret = cmd_find (cmd, - cmd[i].details.gauger.label_stop); - if (GNUNET_SYSERR == ret) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "%d:Undefined reference to %s\n", - i, - cmd[i].details.gauger.label_stop); - return GNUNET_SYSERR; - } - if (PERF_TALER_EXCHANGEDB_TIME != cmd[ret].exposed.type) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "%d:Wrong type reference to %s\n", - i, + ret = cmd_find (cmd, cmd[i].details.gauger.label_stop); - return GNUNET_SYSERR; - } - cmd[i].details.gauger.index_stop = ret; + if (GNUNET_SYSERR == ret) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "%d:Undefined reference to %s\n", + i, + cmd[i].details.gauger.label_stop); + return GNUNET_SYSERR; } - break; - - case PERF_TALER_EXCHANGEDB_CMD_INSERT_DENOMINATION: + if (PERF_TALER_EXCHANGEDB_TIME != cmd[ret].exposed.type) { - int ret; + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "%d:Wrong type reference to %s\n", + i, + cmd[i].details.gauger.label_stop); + return GNUNET_SYSERR; + } + cmd[i].details.gauger.index_stop = ret; + } + break; - ret = cmd_find (cmd, - cmd[i].details.insert_denomination.label_denom); - if (GNUNET_SYSERR == ret) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "%d:Undefined reference to %s\n", - i, - cmd[i].details.insert_denomination.label_denom); - return GNUNET_SYSERR; - } - if (PERF_TALER_EXCHANGEDB_DENOMINATION_INFO != cmd[ret].exposed.type) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "%d:Wrong type reference to %s\n", - i, + case PERF_TALER_EXCHANGEDB_CMD_INSERT_DENOMINATION: + { + int ret; + + ret = cmd_find (cmd, cmd[i].details.insert_denomination.label_denom); - return GNUNET_SYSERR; - } - cmd[i].details.insert_denomination.index_denom = ret; + if (GNUNET_SYSERR == ret) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "%d:Undefined reference to %s\n", + i, + cmd[i].details.insert_denomination.label_denom); + return GNUNET_SYSERR; } - break; - - case PERF_TALER_EXCHANGEDB_CMD_GET_DENOMINATION: + if (PERF_TALER_EXCHANGEDB_DENOMINATION_INFO != cmd[ret].exposed.type) { - int ret; - - ret = cmd_find (cmd, - cmd[i].details.get_denomination.label_denom); - if (GNUNET_SYSERR == ret) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "%d:Undefined reference to %s\n", - i, - cmd[i].details.get_denomination.label_denom); - return GNUNET_SYSERR; - } - if (PERF_TALER_EXCHANGEDB_DENOMINATION_INFO != cmd[ret].exposed.type) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "%d:Wrong type reference to %s\n", - i, - cmd[i].details.get_denomination.label_denom); - return GNUNET_SYSERR; - } - cmd[i].details.get_denomination.index_denom = ret; + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "%d:Wrong type reference to %s\n", + i, + cmd[i].details.insert_denomination.label_denom); + return GNUNET_SYSERR; } - break; + cmd[i].details.insert_denomination.index_denom = ret; + } + break; - case PERF_TALER_EXCHANGEDB_CMD_INSERT_RESERVE: - { - int ret; + case PERF_TALER_EXCHANGEDB_CMD_GET_DENOMINATION: + { + int ret; - ret = cmd_find (cmd, - cmd[i].details.insert_reserve.label_reserve); - if (GNUNET_SYSERR == ret) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "%d:Undefined reference to %s\n", - i, - cmd[i].details.insert_reserve.label_reserve); - return GNUNET_SYSERR; - } - if (PERF_TALER_EXCHANGEDB_RESERVE != cmd[ret].exposed.type) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "%d:Wrong type reference to %s\n", - i, - cmd[i].details.insert_reserve.label_reserve); - return GNUNET_SYSERR; - } - cmd[i].details.insert_reserve.index_reserve = ret; + ret = cmd_find (cmd, + cmd[i].details.get_denomination.label_denom); + if (GNUNET_SYSERR == ret) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "%d:Undefined reference to %s\n", + i, + cmd[i].details.get_denomination.label_denom); + return GNUNET_SYSERR; } - break; - - case PERF_TALER_EXCHANGEDB_CMD_GET_RESERVE: + if (PERF_TALER_EXCHANGEDB_DENOMINATION_INFO != cmd[ret].exposed.type) { - int ret; - - ret = cmd_find (cmd, - cmd[i].details.get_reserve.label_reserve); - if (GNUNET_SYSERR == ret) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "%d:Undefined reference to %s\n", - i, - cmd[i].details.get_reserve.label_reserve); - return GNUNET_SYSERR; - } - if (PERF_TALER_EXCHANGEDB_RESERVE != cmd[ret].exposed.type) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "%d:Wrong type reference to %s\n", - i, - cmd[i].details.get_reserve.label_reserve); - return GNUNET_SYSERR; - } - cmd[i].details.get_reserve.index_reserve = ret; + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "%d:Wrong type reference to %s\n", + i, + cmd[i].details.get_denomination.label_denom); + return GNUNET_SYSERR; } - break; + cmd[i].details.get_denomination.index_denom = ret; + } + break; - case PERF_TALER_EXCHANGEDB_CMD_GET_RESERVE_HISTORY: - { - int ret; + case PERF_TALER_EXCHANGEDB_CMD_INSERT_RESERVE: + { + int ret; - ret = cmd_find (cmd, - cmd[i].details.get_reserve_history.label_reserve); - if (GNUNET_SYSERR == ret) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "%d:Undefined reference to %s\n", - i, - cmd[i].details.get_reserve_history.label_reserve); - return GNUNET_SYSERR; - } - if (PERF_TALER_EXCHANGEDB_RESERVE != cmd[ret].exposed.type) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "%d:Wrong type reference to %s\n", - i, - cmd[i].details.get_reserve_history.label_reserve); - return GNUNET_SYSERR; - } - cmd[i].details.get_reserve_history.index_reserve = ret; + ret = cmd_find (cmd, + cmd[i].details.insert_reserve.label_reserve); + if (GNUNET_SYSERR == ret) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "%d:Undefined reference to %s\n", + i, + cmd[i].details.insert_reserve.label_reserve); + return GNUNET_SYSERR; } - break; - - case PERF_TALER_EXCHANGEDB_CMD_CREATE_WITHDRAW: + if (PERF_TALER_EXCHANGEDB_RESERVE != cmd[ret].exposed.type) { - int ret; - - ret = cmd_find (cmd, - cmd[i].details.create_withdraw.label_dki); - { - if (GNUNET_SYSERR == ret) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "%d:Undefined reference to %s\n", - i, - cmd[i].details.create_withdraw.label_dki); - return GNUNET_SYSERR; - } - if (PERF_TALER_EXCHANGEDB_DENOMINATION_INFO != cmd[ret].exposed.type) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "%d:Wrong type reference to %s\n", - i, - cmd[i].details.create_withdraw.label_dki); - return GNUNET_SYSERR; - } - } - cmd[i].details.create_withdraw.index_dki = ret; - ret = cmd_find (cmd, - cmd[i].details.create_withdraw.label_reserve); - { - if (GNUNET_SYSERR == ret) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "%d:Undefined reference to %s\n", - i, - cmd[i].details.create_withdraw.label_reserve); - return GNUNET_SYSERR; - } - if (PERF_TALER_EXCHANGEDB_RESERVE != cmd[ret].exposed.type) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "%d:Wrong type reference to %s\n", - i, - cmd[i].details.create_withdraw.label_reserve); - return GNUNET_SYSERR; - } - } - cmd[i].details.create_withdraw.index_reserve = ret; + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "%d:Wrong type reference to %s\n", + i, + cmd[i].details.insert_reserve.label_reserve); + return GNUNET_SYSERR; } - break; + cmd[i].details.insert_reserve.index_reserve = ret; + } + break; - case PERF_TALER_EXCHANGEDB_CMD_INSERT_WITHDRAW: - { - int ret; + case PERF_TALER_EXCHANGEDB_CMD_GET_RESERVE: + { + int ret; - ret = cmd_find (cmd, - cmd[i].details.insert_withdraw.label_coin); - if (GNUNET_SYSERR == ret) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "%d:Undefined reference to %s\n", - i, - cmd[i].details.insert_withdraw.label_coin); - return GNUNET_SYSERR; - } - if (PERF_TALER_EXCHANGEDB_COIN != cmd[ret].exposed.type) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "%d:Wrong type reference to %s\n", - i, - cmd[i].details.insert_withdraw.label_coin); - return GNUNET_SYSERR; - } - cmd[i].details.insert_withdraw.index_coin = ret; + ret = cmd_find (cmd, + cmd[i].details.get_reserve.label_reserve); + if (GNUNET_SYSERR == ret) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "%d:Undefined reference to %s\n", + i, + cmd[i].details.get_reserve.label_reserve); + return GNUNET_SYSERR; } - break; - - case PERF_TALER_EXCHANGEDB_CMD_GET_WITHDRAW: + if (PERF_TALER_EXCHANGEDB_RESERVE != cmd[ret].exposed.type) { - int ret; - - ret = cmd_find (cmd, - cmd[i].details.get_withdraw.label_coin); - if (GNUNET_SYSERR == ret) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "%d:Undefined reference to %s\n", - i, - cmd[i].details.get_withdraw.label_coin); - return GNUNET_SYSERR; - } - if (PERF_TALER_EXCHANGEDB_COIN != cmd[ret].exposed.type) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "%d:Wrong type reference to %s\n", - i, - cmd[i].details.get_withdraw.label_coin); - return GNUNET_SYSERR; - } - cmd[i].details.get_withdraw.index_coin = ret; + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "%d:Wrong type reference to %s\n", + i, + cmd[i].details.get_reserve.label_reserve); + return GNUNET_SYSERR; } - break; + cmd[i].details.get_reserve.index_reserve = ret; + } + break; - case PERF_TALER_EXCHANGEDB_CMD_GET_COIN_TRANSACTION: + case PERF_TALER_EXCHANGEDB_CMD_GET_RESERVE_HISTORY: + { + int ret; + + ret = cmd_find (cmd, + cmd[i].details.get_reserve_history.label_reserve); + if (GNUNET_SYSERR == ret) { - int ret; - ret = cmd_find (cmd, - cmd[i].details.get_coin_transaction.label_coin); - if (GNUNET_SYSERR == ret) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "%d:Undefined reference to %s\n", - i, - cmd[i].details.get_coin_transaction.label_coin); - return GNUNET_SYSERR; - } - if (PERF_TALER_EXCHANGEDB_COIN != cmd[ret].exposed.type) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "%d:Wrong type reference to %s\n", - i, - cmd[i].details.get_coin_transaction.label_coin); - return GNUNET_SYSERR; - } - cmd[i].details.get_coin_transaction.index_coin = ret; + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "%d:Undefined reference to %s\n", + i, + cmd[i].details.get_reserve_history.label_reserve); + return GNUNET_SYSERR; } - break; - - case PERF_TALER_EXCHANGEDB_CMD_CREATE_DEPOSIT: + if (PERF_TALER_EXCHANGEDB_RESERVE != cmd[ret].exposed.type) { - int ret; - - ret = cmd_find (cmd, - cmd[i].details.create_deposit.label_coin); - if (GNUNET_SYSERR == ret) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "%d:Undefined reference to %s\n", - i, - cmd[i].details.create_deposit.label_coin); - return GNUNET_SYSERR; - } - if (PERF_TALER_EXCHANGEDB_COIN != cmd[ret].exposed.type) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "%d:Wrong type reference to %s\n", - i, - cmd[i].details.create_deposit.label_coin); - return GNUNET_SYSERR; - } - cmd[i].details.create_deposit.index_coin = ret; + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "%d:Wrong type reference to %s\n", + i, + cmd[i].details.get_reserve_history.label_reserve); + return GNUNET_SYSERR; } - break; + cmd[i].details.get_reserve_history.index_reserve = ret; + } + break; - case PERF_TALER_EXCHANGEDB_CMD_INSERT_DEPOSIT: - { - int ret; + case PERF_TALER_EXCHANGEDB_CMD_CREATE_WITHDRAW: + { + int ret; - ret = cmd_find( cmd, - cmd[i].details.insert_deposit.label_deposit); + ret = cmd_find (cmd, + cmd[i].details.create_withdraw.label_dki); + { if (GNUNET_SYSERR == ret) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%d:Undefined reference to %s\n", i, - cmd[i].details.insert_deposit.label_deposit); + cmd[i].details.create_withdraw.label_dki); return GNUNET_SYSERR; } - if (PERF_TALER_EXCHANGEDB_DEPOSIT != cmd[ret].exposed.type) + if (PERF_TALER_EXCHANGEDB_DENOMINATION_INFO != cmd[ret].exposed.type) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%d:Wrong type reference to %s\n", i, - cmd[i].details.insert_deposit.label_deposit); + cmd[i].details.create_withdraw.label_dki); return GNUNET_SYSERR; } - cmd[i].details.insert_deposit.index_deposit = ret; } - break; - - case PERF_TALER_EXCHANGEDB_CMD_GET_DEPOSIT: + cmd[i].details.create_withdraw.index_dki = ret; + ret = cmd_find (cmd, + cmd[i].details.create_withdraw.label_reserve); { - int ret; - - ret = cmd_find (cmd, - cmd[i].details.get_deposit.label_deposit); if (GNUNET_SYSERR == ret) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%d:Undefined reference to %s\n", i, - cmd[i].details.get_deposit.label_deposit); + cmd[i].details.create_withdraw.label_reserve); return GNUNET_SYSERR; } - if (PERF_TALER_EXCHANGEDB_DEPOSIT != cmd[ret].exposed.type) + if (PERF_TALER_EXCHANGEDB_RESERVE != cmd[ret].exposed.type) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%d:Wrong type reference to %s\n", i, - cmd[i].details.get_deposit.label_deposit); + cmd[i].details.create_withdraw.label_reserve); return GNUNET_SYSERR; } - cmd[i].details.get_deposit.index_deposit = ret; } - break; + cmd[i].details.create_withdraw.index_reserve = ret; + } + break; - case PERF_TALER_EXCHANGEDB_CMD_CREATE_REFRESH_SESSION: + case PERF_TALER_EXCHANGEDB_CMD_INSERT_WITHDRAW: + { + int ret; + + ret = cmd_find (cmd, + cmd[i].details.insert_withdraw.label_coin); + if (GNUNET_SYSERR == ret) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "%d:Undefined reference to %s\n", + i, + cmd[i].details.insert_withdraw.label_coin); + return GNUNET_SYSERR; + } + if (PERF_TALER_EXCHANGEDB_COIN != cmd[ret].exposed.type) { - int ret; + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "%d:Wrong type reference to %s\n", + i, + cmd[i].details.insert_withdraw.label_coin); + return GNUNET_SYSERR; + } + cmd[i].details.insert_withdraw.index_coin = ret; + } + break; - ret = cmd_find (cmd, - cmd[i].details.create_refresh_session.label_coin); - if (GNUNET_SYSERR == ret) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "%d:Undefined reference to %s at %s\n", - i, - cmd[i].details.create_refresh_session.label_coin, - cmd[i].label); - return GNUNET_SYSERR; - } - if (PERF_TALER_EXCHANGEDB_COIN != cmd[ret].exposed.type) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "%d:Wrong type reference to %s at %s\n", - i, - cmd[i].details.create_refresh_session.label_coin, - cmd[i].label); - return GNUNET_SYSERR; - } - cmd[i].details.create_refresh_session.index_coin = ret; + case PERF_TALER_EXCHANGEDB_CMD_GET_WITHDRAW: + { + int ret; + + ret = cmd_find (cmd, + cmd[i].details.get_withdraw.label_coin); + if (GNUNET_SYSERR == ret) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "%d:Undefined reference to %s\n", + i, + cmd[i].details.get_withdraw.label_coin); + return GNUNET_SYSERR; } - break; + if (PERF_TALER_EXCHANGEDB_COIN != cmd[ret].exposed.type) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "%d:Wrong type reference to %s\n", + i, + cmd[i].details.get_withdraw.label_coin); + return GNUNET_SYSERR; + } + cmd[i].details.get_withdraw.index_coin = ret; + } + break; - case PERF_TALER_EXCHANGEDB_CMD_GET_REFRESH_SESSION: + case PERF_TALER_EXCHANGEDB_CMD_GET_COIN_TRANSACTION: + { + int ret; + ret = cmd_find (cmd, + cmd[i].details.get_coin_transaction.label_coin); + if (GNUNET_SYSERR == ret) { - int ret; + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "%d:Undefined reference to %s\n", + i, + cmd[i].details.get_coin_transaction.label_coin); + return GNUNET_SYSERR; + } + if (PERF_TALER_EXCHANGEDB_COIN != cmd[ret].exposed.type) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "%d:Wrong type reference to %s\n", + i, + cmd[i].details.get_coin_transaction.label_coin); + return GNUNET_SYSERR; + } + cmd[i].details.get_coin_transaction.index_coin = ret; + } + break; - ret = cmd_find (cmd, - cmd[i].details.get_refresh_session.label_hash); - if (GNUNET_SYSERR == ret) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "%d:Undefined reference to %s at %s\n", - i, - cmd[i].details.get_refresh_session.label_hash, - cmd[i].label); - return GNUNET_SYSERR; - } - if (PERF_TALER_EXCHANGEDB_REFRESH_HASH != cmd[ret].exposed.type) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "%d:Wrong type reference to %s at %s\n", - i, - cmd[i].details.get_refresh_session.label_hash, - cmd[i].label); - return GNUNET_SYSERR; - } - cmd[i].details.get_refresh_session.index_hash = ret; + case PERF_TALER_EXCHANGEDB_CMD_CREATE_DEPOSIT: + { + int ret; + + ret = cmd_find (cmd, + cmd[i].details.create_deposit.label_coin); + if (GNUNET_SYSERR == ret) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "%d:Undefined reference to %s\n", + i, + cmd[i].details.create_deposit.label_coin); + return GNUNET_SYSERR; + } + if (PERF_TALER_EXCHANGEDB_COIN != cmd[ret].exposed.type) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "%d:Wrong type reference to %s\n", + i, + cmd[i].details.create_deposit.label_coin); + return GNUNET_SYSERR; } - break; + cmd[i].details.create_deposit.index_coin = ret; + } + break; + + case PERF_TALER_EXCHANGEDB_CMD_INSERT_DEPOSIT: + { + int ret; - case PERF_TALER_EXCHANGEDB_CMD_INSERT_REFRESH_REVEAL: + ret = cmd_find (cmd, + cmd[i].details.insert_deposit.label_deposit); + if (GNUNET_SYSERR == ret) { - int ret; - ret = cmd_find (cmd, - cmd[i].details.insert_refresh_reveal.label_hash); - if (GNUNET_SYSERR == ret) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "%d:Undefined reference to %s\n", - i, - cmd[i].details.insert_refresh_reveal.label_hash); - return GNUNET_SYSERR; - } - if (PERF_TALER_EXCHANGEDB_REFRESH_HASH != cmd[ret].exposed.type) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "%d:Wrong type reference to %s\n", - i, + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "%d:Undefined reference to %s\n", + i, + cmd[i].details.insert_deposit.label_deposit); + return GNUNET_SYSERR; + } + if (PERF_TALER_EXCHANGEDB_DEPOSIT != cmd[ret].exposed.type) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "%d:Wrong type reference to %s\n", + i, + cmd[i].details.insert_deposit.label_deposit); + return GNUNET_SYSERR; + } + cmd[i].details.insert_deposit.index_deposit = ret; + } + break; + + case PERF_TALER_EXCHANGEDB_CMD_GET_DEPOSIT: + { + int ret; + + ret = cmd_find (cmd, + cmd[i].details.get_deposit.label_deposit); + if (GNUNET_SYSERR == ret) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "%d:Undefined reference to %s\n", + i, + cmd[i].details.get_deposit.label_deposit); + return GNUNET_SYSERR; + } + if (PERF_TALER_EXCHANGEDB_DEPOSIT != cmd[ret].exposed.type) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "%d:Wrong type reference to %s\n", + i, + cmd[i].details.get_deposit.label_deposit); + return GNUNET_SYSERR; + } + cmd[i].details.get_deposit.index_deposit = ret; + } + break; + + case PERF_TALER_EXCHANGEDB_CMD_CREATE_REFRESH_SESSION: + { + int ret; + + ret = cmd_find (cmd, + cmd[i].details.create_refresh_session.label_coin); + if (GNUNET_SYSERR == ret) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "%d:Undefined reference to %s at %s\n", + i, + cmd[i].details.create_refresh_session.label_coin, + cmd[i].label); + return GNUNET_SYSERR; + } + if (PERF_TALER_EXCHANGEDB_COIN != cmd[ret].exposed.type) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "%d:Wrong type reference to %s at %s\n", + i, + cmd[i].details.create_refresh_session.label_coin, + cmd[i].label); + return GNUNET_SYSERR; + } + cmd[i].details.create_refresh_session.index_coin = ret; + } + break; + + case PERF_TALER_EXCHANGEDB_CMD_GET_REFRESH_SESSION: + { + int ret; + + ret = cmd_find (cmd, + cmd[i].details.get_refresh_session.label_hash); + if (GNUNET_SYSERR == ret) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "%d:Undefined reference to %s at %s\n", + i, + cmd[i].details.get_refresh_session.label_hash, + cmd[i].label); + return GNUNET_SYSERR; + } + if (PERF_TALER_EXCHANGEDB_REFRESH_HASH != cmd[ret].exposed.type) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "%d:Wrong type reference to %s at %s\n", + i, + cmd[i].details.get_refresh_session.label_hash, + cmd[i].label); + return GNUNET_SYSERR; + } + cmd[i].details.get_refresh_session.index_hash = ret; + } + break; + + case PERF_TALER_EXCHANGEDB_CMD_INSERT_REFRESH_REVEAL: + { + int ret; + ret = cmd_find (cmd, cmd[i].details.insert_refresh_reveal.label_hash); - return GNUNET_SYSERR; - } - cmd[i].details.insert_refresh_reveal.index_hash = ret; + if (GNUNET_SYSERR == ret) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "%d:Undefined reference to %s\n", + i, + cmd[i].details.insert_refresh_reveal.label_hash); + return GNUNET_SYSERR; + } + if (PERF_TALER_EXCHANGEDB_REFRESH_HASH != cmd[ret].exposed.type) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "%d:Wrong type reference to %s\n", + i, + cmd[i].details.insert_refresh_reveal.label_hash); + return GNUNET_SYSERR; + } + cmd[i].details.insert_refresh_reveal.index_hash = ret; - ret = cmd_find (cmd, - cmd[i].details.insert_refresh_reveal.label_denom); - if (GNUNET_SYSERR == ret) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "%d:Undefined reference to %s\n", - i, - cmd[i].details.insert_refresh_reveal.label_denom); - return GNUNET_SYSERR; - } - if (PERF_TALER_EXCHANGEDB_DENOMINATION_INFO != cmd[ret].exposed.type) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "%d:Wrong type reference to %s\n", - i, + ret = cmd_find (cmd, cmd[i].details.insert_refresh_reveal.label_denom); - return GNUNET_SYSERR; - } - cmd[i].details.insert_refresh_reveal.index_denom = ret; + if (GNUNET_SYSERR == ret) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "%d:Undefined reference to %s\n", + i, + cmd[i].details.insert_refresh_reveal.label_denom); + return GNUNET_SYSERR; } - break; - - case PERF_TALER_EXCHANGEDB_CMD_GET_REFRESH_REVEAL: + if (PERF_TALER_EXCHANGEDB_DENOMINATION_INFO != cmd[ret].exposed.type) { - int ret; - ret = cmd_find (cmd, - cmd[i].details.get_refresh_reveal.label_hash); - if (GNUNET_SYSERR == ret) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "%d:Undefined reference to %s\n", - i, - cmd[i].details.get_refresh_reveal.label_hash); - return GNUNET_SYSERR; - } - if (PERF_TALER_EXCHANGEDB_REFRESH_HASH != cmd[ret].exposed.type) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "%d:Wrong type reference to %s\n", - i, + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "%d:Wrong type reference to %s\n", + i, + cmd[i].details.insert_refresh_reveal.label_denom); + return GNUNET_SYSERR; + } + cmd[i].details.insert_refresh_reveal.index_denom = ret; + } + break; + + case PERF_TALER_EXCHANGEDB_CMD_GET_REFRESH_REVEAL: + { + int ret; + ret = cmd_find (cmd, cmd[i].details.get_refresh_reveal.label_hash); - return GNUNET_SYSERR; - } - cmd[i].details.get_refresh_reveal.index_hash = ret; + if (GNUNET_SYSERR == ret) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "%d:Undefined reference to %s\n", + i, + cmd[i].details.get_refresh_reveal.label_hash); + return GNUNET_SYSERR; + } + if (PERF_TALER_EXCHANGEDB_REFRESH_HASH != cmd[ret].exposed.type) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "%d:Wrong type reference to %s\n", + i, + cmd[i].details.get_refresh_reveal.label_hash); + return GNUNET_SYSERR; } - break; + cmd[i].details.get_refresh_reveal.index_hash = ret; + } + break; - case PERF_TALER_EXCHANGEDB_CMD_GET_LINK_DATA: - { - int ret; - ret = cmd_find (cmd, - cmd[i].details.get_link_data_list.label_hash); - if (GNUNET_SYSERR == ret) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "%d:Undefined reference to %s\n", - i, - cmd[i].details.get_link_data_list.label_hash); - return GNUNET_SYSERR; - } - if (PERF_TALER_EXCHANGEDB_REFRESH_HASH != cmd[ret].exposed.type) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "%d:Wrong type reference to %s\n", - i, + case PERF_TALER_EXCHANGEDB_CMD_GET_LINK_DATA: + { + int ret; + ret = cmd_find (cmd, cmd[i].details.get_link_data_list.label_hash); - return GNUNET_SYSERR; - } - cmd[i].details.get_link_data_list.index_hash = ret; + if (GNUNET_SYSERR == ret) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "%d:Undefined reference to %s\n", + i, + cmd[i].details.get_link_data_list.label_hash); + return GNUNET_SYSERR; + } + if (PERF_TALER_EXCHANGEDB_REFRESH_HASH != cmd[ret].exposed.type) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "%d:Wrong type reference to %s\n", + i, + cmd[i].details.get_link_data_list.label_hash); + return GNUNET_SYSERR; } - break; - - case PERF_TALER_EXCHANGEDB_CMD_END: - case PERF_TALER_EXCHANGEDB_CMD_DEBUG: - case PERF_TALER_EXCHANGEDB_CMD_LOOP: - case PERF_TALER_EXCHANGEDB_CMD_NEW_SESSION: - case PERF_TALER_EXCHANGEDB_CMD_START_TRANSACTION: - case PERF_TALER_EXCHANGEDB_CMD_COMMIT_TRANSACTION: - case PERF_TALER_EXCHANGEDB_CMD_ABORT_TRANSACTION: - case PERF_TALER_EXCHANGEDB_CMD_GET_TIME: - case PERF_TALER_EXCHANGEDB_CMD_CREATE_DENOMINATION: - case PERF_TALER_EXCHANGEDB_CMD_CREATE_RESERVE: - break; + cmd[i].details.get_link_data_list.index_hash = ret; + } + break; + + case PERF_TALER_EXCHANGEDB_CMD_END: + case PERF_TALER_EXCHANGEDB_CMD_DEBUG: + case PERF_TALER_EXCHANGEDB_CMD_LOOP: + case PERF_TALER_EXCHANGEDB_CMD_NEW_SESSION: + case PERF_TALER_EXCHANGEDB_CMD_START_TRANSACTION: + case PERF_TALER_EXCHANGEDB_CMD_COMMIT_TRANSACTION: + case PERF_TALER_EXCHANGEDB_CMD_ABORT_TRANSACTION: + case PERF_TALER_EXCHANGEDB_CMD_GET_TIME: + case PERF_TALER_EXCHANGEDB_CMD_CREATE_DENOMINATION: + case PERF_TALER_EXCHANGEDB_CMD_CREATE_RESERVE: + break; } } return GNUNET_OK; @@ -897,30 +900,30 @@ cmd_clean (struct PERF_TALER_EXCHANGEDB_Cmd cmd[]) { unsigned int i; - for (i=0; PERF_TALER_EXCHANGEDB_CMD_END != cmd[i].command; i++) + for (i = 0; PERF_TALER_EXCHANGEDB_CMD_END != cmd[i].command; i++) { switch (cmd[i].command) { - case PERF_TALER_EXCHANGEDB_CMD_SAVE_ARRAY: - { - unsigned int j; + case PERF_TALER_EXCHANGEDB_CMD_SAVE_ARRAY: + { + unsigned int j; - for (j = 0; j < cmd[i].details.save_array.nb_saved; j++) - { - data_free (&cmd[i].details.save_array.data_saved[j]); - } - GNUNET_free (cmd[i].details.save_array.data_saved); - cmd[i].details.save_array.data_saved = NULL; + for (j = 0; j < cmd[i].details.save_array.nb_saved; j++) + { + data_free (&cmd[i].details.save_array.data_saved[j]); } - break; + GNUNET_free (cmd[i].details.save_array.data_saved); + cmd[i].details.save_array.data_saved = NULL; + } + break; - case PERF_TALER_EXCHANGEDB_CMD_LOAD_ARRAY: - GNUNET_free (cmd[i].details.load_array.permutation); - cmd[i].details.load_array.permutation = NULL; - break; + case PERF_TALER_EXCHANGEDB_CMD_LOAD_ARRAY: + GNUNET_free (cmd[i].details.load_array.permutation); + cmd[i].details.load_array.permutation = NULL; + break; - default: - break; + default: + break; } data_free (&cmd[i].exposed); } @@ -986,27 +989,28 @@ interpret_save_array (struct PERF_TALER_EXCHANGEDB_interpreter_state *state) } /* The probability distribution of the saved items will be a little biased against the few last items but it should not be a big problem. */ - selection_chance = loop_ref->details.loop.max_iterations / - cmd->details.save_array.nb_saved; + selection_chance = loop_ref->details.loop.max_iterations + / cmd->details.save_array.nb_saved; /* * If the remaining space is equal to the remaining number of * iterations, the item is automaticly saved. * * Else it is saved only if the random numbre generated is 0 */ - if ( (0 < (cmd->details.save_array.nb_saved - - cmd->details.save_array.index) ) && - ( ((loop_ref->details.loop.max_iterations - - loop_ref->details.loop.curr_iteration) == - (cmd->details.save_array.nb_saved - - cmd->details.save_array.index)) || + if ( (0 < (cmd->details.save_array.nb_saved + - cmd->details.save_array.index) ) && + ( ((loop_ref->details.loop.max_iterations + - loop_ref->details.loop.curr_iteration) == + (cmd->details.save_array.nb_saved + - cmd->details.save_array.index)) || (0 == GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, selection_chance)) ) ) { struct PERF_TALER_EXCHANGEDB_Data *save_location; struct PERF_TALER_EXCHANGEDB_Data *item_saved; - save_location = &cmd->details.save_array.data_saved[cmd->details.save_array.index]; + save_location = + &cmd->details.save_array.data_saved[cmd->details.save_array.index]; item_saved = &save_ref->exposed; data_copy (item_saved, save_location); cmd->details.save_array.index++; @@ -1039,13 +1043,14 @@ interpret_load_array (struct PERF_TALER_EXCHANGEDB_interpreter_state *state) * the number is run several times in the permutation array */ quotient = loop_iter / state->cmd[save_index].details.save_array.nb_saved; loop_iter = loop_iter % state->cmd[save_index].details.save_array.nb_saved; - for (i=0; i<=quotient; i++) + for (i = 0; i<=quotient; i++) loop_iter = cmd->details.load_array.permutation[loop_iter]; } /* Extracting the data from the loop_indexth indice in save_index * array. */ - loaded_data = &state->cmd[save_index].details.save_array.data_saved[loop_iter]; + loaded_data = + &state->cmd[save_index].details.save_array.data_saved[loop_iter]; data_copy (loaded_data, &cmd->exposed); } @@ -1065,7 +1070,8 @@ interprete_load_random (struct PERF_TALER_EXCHANGEDB_interpreter_state *state) save_index = cmd->details.load_random.index_save; index = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, - state->cmd[save_index].details.save_array.nb_saved); + state->cmd[save_index].details.save_array. + nb_saved); data_copy (&state->cmd[save_index].details.save_array.data_saved[index], &cmd->exposed); } @@ -1102,428 +1108,449 @@ refresh_reveal_cb (void *cls, static int interpret (struct PERF_TALER_EXCHANGEDB_interpreter_state *state) { - for (state->i=0; PERF_TALER_EXCHANGEDB_CMD_END != state->cmd[state->i].command; state->i++) + for (state->i = 0; PERF_TALER_EXCHANGEDB_CMD_END != + state->cmd[state->i].command; state->i++) { switch (state->cmd[state->i].command) { - case PERF_TALER_EXCHANGEDB_CMD_END: - return GNUNET_YES; - - case PERF_TALER_EXCHANGEDB_CMD_DEBUG: - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "%s\n", - state->cmd[state->i].label); - break; - - case PERF_TALER_EXCHANGEDB_CMD_LOOP: - break; - - case PERF_TALER_EXCHANGEDB_CMD_END_LOOP: - interpret_end_loop (state); - break; - - case PERF_TALER_EXCHANGEDB_CMD_GET_TIME: - state->cmd[state->i].exposed.data.time = - GNUNET_new (struct GNUNET_TIME_Absolute); - *state->cmd[state->i].exposed.data.time = - GNUNET_TIME_absolute_get (); - break; - - case PERF_TALER_EXCHANGEDB_CMD_GAUGER: - { - unsigned int start_index; - unsigned int stop_index; - float ips; - struct GNUNET_TIME_Absolute start; - struct GNUNET_TIME_Absolute stop; - struct GNUNET_TIME_Relative elapsed; - - start_index = state->cmd[state->i].details.gauger.index_start; - stop_index = state->cmd[state->i].details.gauger.index_stop; - start = *state->cmd[start_index].exposed.data.time; - stop = *state->cmd[stop_index].exposed.data.time; - elapsed = GNUNET_TIME_absolute_get_difference (start, - stop); - ips = (1.0 * state->cmd[state->i].details.gauger.divide) / (elapsed.rel_value_us/1000000.0); - GAUGER (state->cmd[state->i].details.gauger.category, - state->cmd[state->i].details.gauger.description, - ips, - state->cmd[state->i].details.gauger.unit); - } - break; + case PERF_TALER_EXCHANGEDB_CMD_END: + return GNUNET_YES; - case PERF_TALER_EXCHANGEDB_CMD_NEW_SESSION: - state->session = state->plugin->get_session (state->plugin->cls); - break; + case PERF_TALER_EXCHANGEDB_CMD_DEBUG: + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "%s\n", + state->cmd[state->i].label); + break; - case PERF_TALER_EXCHANGEDB_CMD_START_TRANSACTION: - GNUNET_break (GNUNET_OK == - state->plugin->start (state->plugin->cls, - state->session, - "perf-interpreter")); - break; - - case PERF_TALER_EXCHANGEDB_CMD_COMMIT_TRANSACTION: - GNUNET_break (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == - state->plugin->commit (state->plugin->cls, - state->session)); - break; - case PERF_TALER_EXCHANGEDB_CMD_ABORT_TRANSACTION: - state->plugin->rollback (state->plugin->cls, - state->session); - break; - - case PERF_TALER_EXCHANGEDB_CMD_SAVE_ARRAY: - interpret_save_array (state); - break; - - case PERF_TALER_EXCHANGEDB_CMD_LOAD_ARRAY: - interpret_load_array (state); - break; - - case PERF_TALER_EXCHANGEDB_CMD_LOAD_RANDOM: - interprete_load_random (state); - break; - - case PERF_TALER_EXCHANGEDB_CMD_CREATE_DEPOSIT: - { - int coin_index; - struct TALER_EXCHANGEDB_Deposit *deposit; + case PERF_TALER_EXCHANGEDB_CMD_LOOP: + break; - coin_index = state->cmd[state->i].details.create_deposit.index_coin; - deposit = PERF_TALER_EXCHANGEDB_deposit_init (state->cmd[coin_index].exposed.data.coin); - GNUNET_assert (NULL != deposit); - state->cmd[state->i].exposed.data.deposit = deposit; - } - break; + case PERF_TALER_EXCHANGEDB_CMD_END_LOOP: + interpret_end_loop (state); + break; - case PERF_TALER_EXCHANGEDB_CMD_INSERT_DEPOSIT: - { - int deposit_index; - enum GNUNET_DB_QueryStatus qs; - struct TALER_EXCHANGEDB_Deposit *deposit; + case PERF_TALER_EXCHANGEDB_CMD_GET_TIME: + state->cmd[state->i].exposed.data.time = + GNUNET_new (struct GNUNET_TIME_Absolute); + *state->cmd[state->i].exposed.data.time = + GNUNET_TIME_absolute_get (); + break; - deposit_index = state->cmd[state->i].details.insert_deposit.index_deposit; - deposit = state->cmd[deposit_index].exposed.data.deposit; - qs = state->plugin->ensure_coin_known (state->plugin->cls, - state->session, - &deposit->coin); - GNUNET_assert (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qs); - qs = state->plugin->insert_deposit (state->plugin->cls, - state->session, - deposit); - GNUNET_assert (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qs); - state->cmd[state->i].exposed.data.deposit - = PERF_TALER_EXCHANGEDB_deposit_copy (deposit); - } - break; + case PERF_TALER_EXCHANGEDB_CMD_GAUGER: + { + unsigned int start_index; + unsigned int stop_index; + float ips; + struct GNUNET_TIME_Absolute start; + struct GNUNET_TIME_Absolute stop; + struct GNUNET_TIME_Relative elapsed; + + start_index = state->cmd[state->i].details.gauger.index_start; + stop_index = state->cmd[state->i].details.gauger.index_stop; + start = *state->cmd[start_index].exposed.data.time; + stop = *state->cmd[stop_index].exposed.data.time; + elapsed = GNUNET_TIME_absolute_get_difference (start, + stop); + ips = (1.0 * state->cmd[state->i].details.gauger.divide) + / (elapsed.rel_value_us / 1000000.0); + GAUGER (state->cmd[state->i].details.gauger.category, + state->cmd[state->i].details.gauger.description, + ips, + state->cmd[state->i].details.gauger.unit); + } + break; - case PERF_TALER_EXCHANGEDB_CMD_GET_DEPOSIT: - { - unsigned int source_index; - enum GNUNET_DB_QueryStatus ret; - struct PERF_TALER_EXCHANGEDB_Data *data; - - source_index = state->cmd[state->i].details.get_deposit.index_deposit; - data = &state->cmd[source_index].exposed; - ret = state->plugin->have_deposit (state->plugin->cls, - state->session, - data->data.deposit, - GNUNET_YES); - GNUNET_assert (0 >= ret); - } - break; + case PERF_TALER_EXCHANGEDB_CMD_NEW_SESSION: + state->session = state->plugin->get_session (state->plugin->cls); + break; - case PERF_TALER_EXCHANGEDB_CMD_CREATE_RESERVE: - { - struct PERF_TALER_EXCHANGEDB_Reserve *reserve; + case PERF_TALER_EXCHANGEDB_CMD_START_TRANSACTION: + GNUNET_break (GNUNET_OK == + state->plugin->start (state->plugin->cls, + state->session, + "perf-interpreter")); + break; - reserve = PERF_TALER_EXCHANGEDB_reserve_init (); - state->cmd[state->i].exposed.data.reserve = reserve; - } - break; + case PERF_TALER_EXCHANGEDB_CMD_COMMIT_TRANSACTION: + GNUNET_break (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == + state->plugin->commit (state->plugin->cls, + state->session)); + break; + case PERF_TALER_EXCHANGEDB_CMD_ABORT_TRANSACTION: + state->plugin->rollback (state->plugin->cls, + state->session); + break; - case PERF_TALER_EXCHANGEDB_CMD_INSERT_RESERVE: - { - unsigned int reserve_index; - int ret; - struct PERF_TALER_EXCHANGEDB_Reserve *reserve; - char *sndr; - uint32_t uid; - struct GNUNET_TIME_Absolute now; - - reserve_index = state->cmd[state->i].details.insert_reserve.index_reserve; - reserve = state->cmd[reserve_index].exposed.data.reserve; - GNUNET_asprintf (&sndr, - "payto://x-taler-test/localhost:8080/%u", - (unsigned int) GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, - UINT32_MAX)); - uid = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, - UINT32_MAX); - now = GNUNET_TIME_absolute_get (); - (void) GNUNET_TIME_round_abs (&now); - ret = state->plugin->reserves_in_insert (state->plugin->cls, - state->session, - &reserve->reserve.pub, - &reserve->reserve.balance, - now, - sndr, - "account-1", - &uid, - sizeof (uid)); - GNUNET_assert (GNUNET_SYSERR != ret); - GNUNET_free (sndr); - } - break; + case PERF_TALER_EXCHANGEDB_CMD_SAVE_ARRAY: + interpret_save_array (state); + break; - case PERF_TALER_EXCHANGEDB_CMD_GET_RESERVE: - { - unsigned int reserve_index; - int ret; - struct PERF_TALER_EXCHANGEDB_Data *data; + case PERF_TALER_EXCHANGEDB_CMD_LOAD_ARRAY: + interpret_load_array (state); + break; + case PERF_TALER_EXCHANGEDB_CMD_LOAD_RANDOM: + interprete_load_random (state); + break; + + case PERF_TALER_EXCHANGEDB_CMD_CREATE_DEPOSIT: + { + int coin_index; + struct TALER_EXCHANGEDB_Deposit *deposit; + + coin_index = state->cmd[state->i].details.create_deposit.index_coin; + deposit = PERF_TALER_EXCHANGEDB_deposit_init ( + state->cmd[coin_index].exposed.data.coin); + GNUNET_assert (NULL != deposit); + state->cmd[state->i].exposed.data.deposit = deposit; + } + break; - reserve_index = state->cmd[state->i].details.get_reserve.index_reserve; - data = &state->cmd[reserve_index].exposed; - ret = state->plugin->reserve_get (state->plugin->cls, + case PERF_TALER_EXCHANGEDB_CMD_INSERT_DEPOSIT: + { + int deposit_index; + enum GNUNET_DB_QueryStatus qs; + struct TALER_EXCHANGEDB_Deposit *deposit; + + deposit_index = + state->cmd[state->i].details.insert_deposit.index_deposit; + deposit = state->cmd[deposit_index].exposed.data.deposit; + qs = state->plugin->ensure_coin_known (state->plugin->cls, + state->session, + &deposit->coin); + GNUNET_assert (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qs); + qs = state->plugin->insert_deposit (state->plugin->cls, state->session, - &data->data.reserve->reserve); - GNUNET_assert (GNUNET_OK == ret); - } - break; + deposit); + GNUNET_assert (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qs); + state->cmd[state->i].exposed.data.deposit + = PERF_TALER_EXCHANGEDB_deposit_copy (deposit); + } + break; - case PERF_TALER_EXCHANGEDB_CMD_GET_RESERVE_HISTORY: - { - unsigned int reserve_index; - struct TALER_EXCHANGEDB_ReserveHistory *history; - struct PERF_TALER_EXCHANGEDB_Data *data; - enum GNUNET_DB_QueryStatus qs; - - reserve_index = state->cmd[state->i].details.get_reserve_history.index_reserve; - data = &state->cmd[reserve_index].exposed; - qs = state->plugin->get_reserve_history (state->plugin->cls, - state->session, - &data->data.reserve->reserve.pub, - &history); - GNUNET_assert (0 >= qs); - GNUNET_assert (NULL != history); - state->plugin->free_reserve_history (state->plugin->cls, - history); - } - break; + case PERF_TALER_EXCHANGEDB_CMD_GET_DEPOSIT: + { + unsigned int source_index; + enum GNUNET_DB_QueryStatus ret; + struct PERF_TALER_EXCHANGEDB_Data *data; + + source_index = state->cmd[state->i].details.get_deposit.index_deposit; + data = &state->cmd[source_index].exposed; + ret = state->plugin->have_deposit (state->plugin->cls, + state->session, + data->data.deposit, + GNUNET_YES); + GNUNET_assert (0 >= ret); + } + break; - case PERF_TALER_EXCHANGEDB_CMD_CREATE_DENOMINATION: - { - struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *dki = - PERF_TALER_EXCHANGEDB_denomination_init (); - GNUNET_assert (NULL != dki); - state->cmd[state->i].exposed.data.dki = dki; - } - break; + case PERF_TALER_EXCHANGEDB_CMD_CREATE_RESERVE: + { + struct PERF_TALER_EXCHANGEDB_Reserve *reserve; - case PERF_TALER_EXCHANGEDB_CMD_INSERT_DENOMINATION: - { - unsigned int denom_index; - enum GNUNET_DB_QueryStatus ret; - struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *dki ; + reserve = PERF_TALER_EXCHANGEDB_reserve_init (); + state->cmd[state->i].exposed.data.reserve = reserve; + } + break; - denom_index = state->cmd[state->i].details.insert_denomination.index_denom; - dki = state->cmd[denom_index].exposed.data.dki; - ret = state->plugin->insert_denomination_info (state->plugin->cls, - state->session, - &dki->denom_pub, - &dki->issue); - GNUNET_assert (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == ret); - } - break; + case PERF_TALER_EXCHANGEDB_CMD_INSERT_RESERVE: + { + unsigned int reserve_index; + int ret; + struct PERF_TALER_EXCHANGEDB_Reserve *reserve; + char *sndr; + uint32_t uid; + struct GNUNET_TIME_Absolute now; + + reserve_index = + state->cmd[state->i].details.insert_reserve.index_reserve; + reserve = state->cmd[reserve_index].exposed.data.reserve; + GNUNET_asprintf (&sndr, + "payto://x-taler-test/localhost:8080/%u", + (unsigned int) GNUNET_CRYPTO_random_u32 ( + GNUNET_CRYPTO_QUALITY_WEAK, + UINT32_MAX)); + uid = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, + UINT32_MAX); + now = GNUNET_TIME_absolute_get (); + (void) GNUNET_TIME_round_abs (&now); + ret = state->plugin->reserves_in_insert (state->plugin->cls, + state->session, + &reserve->reserve.pub, + &reserve->reserve.balance, + now, + sndr, + "account-1", + &uid, + sizeof (uid)); + GNUNET_assert (GNUNET_SYSERR != ret); + GNUNET_free (sndr); + } + break; - case PERF_TALER_EXCHANGEDB_CMD_GET_DENOMINATION: - { - unsigned int denom_index; - enum GNUNET_DB_QueryStatus qs; - struct PERF_TALER_EXCHANGEDB_Data *data; - struct GNUNET_HashCode hc; - - denom_index = state->cmd[state->i].details.get_denomination.index_denom; - data = &state->cmd[denom_index].exposed; - GNUNET_CRYPTO_rsa_public_key_hash (data->data.dki->denom_pub.rsa_public_key, - &hc); - qs = state->plugin->get_denomination_info (state->plugin->cls, - state->session, - &hc, - &data->data.dki->issue); - GNUNET_assert (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qs); - } - break; + case PERF_TALER_EXCHANGEDB_CMD_GET_RESERVE: + { + unsigned int reserve_index; + int ret; + struct PERF_TALER_EXCHANGEDB_Data *data; - case PERF_TALER_EXCHANGEDB_CMD_CREATE_WITHDRAW: - { - unsigned int dki_index; - unsigned int reserve_index; - struct PERF_TALER_EXCHANGEDB_Coin *coin; - - dki_index = state->cmd[state->i].details.create_withdraw.index_dki; - reserve_index = state->cmd[state->i].details.create_withdraw.index_reserve; - coin = PERF_TALER_EXCHANGEDB_coin_init (state->cmd[dki_index].exposed.data.dki, - state->cmd[reserve_index].exposed.data.reserve); - GNUNET_assert (NULL != coin); - state->cmd[state->i].exposed.data.coin = coin; - } - break; - case PERF_TALER_EXCHANGEDB_CMD_INSERT_WITHDRAW: - { - unsigned int coin_index; - enum GNUNET_DB_QueryStatus qs; - struct PERF_TALER_EXCHANGEDB_Coin *coin; - - coin_index = state->cmd[state->i].details.insert_withdraw.index_coin; - coin = state->cmd[coin_index].exposed.data.coin; - qs = state->plugin->insert_withdraw_info (state->plugin->cls, - state->session, - &coin->blind); - GNUNET_assert (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qs); - } - break; + reserve_index = state->cmd[state->i].details.get_reserve.index_reserve; + data = &state->cmd[reserve_index].exposed; + ret = state->plugin->reserve_get (state->plugin->cls, + state->session, + &data->data.reserve->reserve); + GNUNET_assert (GNUNET_OK == ret); + } + break; - case PERF_TALER_EXCHANGEDB_CMD_GET_WITHDRAW: - { - unsigned int source_index; - enum GNUNET_DB_QueryStatus qs; - struct PERF_TALER_EXCHANGEDB_Data *data; - - source_index = state->cmd[state->i].details.get_denomination.index_denom; - data = &state->cmd[source_index].exposed; - qs = state->plugin->get_withdraw_info (state->plugin->cls, - state->session, - &data->data.coin->blind.h_coin_envelope, - &data->data.coin->blind); - GNUNET_assert (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qs); - } - break; + case PERF_TALER_EXCHANGEDB_CMD_GET_RESERVE_HISTORY: + { + unsigned int reserve_index; + struct TALER_EXCHANGEDB_ReserveHistory *history; + struct PERF_TALER_EXCHANGEDB_Data *data; + enum GNUNET_DB_QueryStatus qs; + + reserve_index = + state->cmd[state->i].details.get_reserve_history.index_reserve; + data = &state->cmd[reserve_index].exposed; + qs = state->plugin->get_reserve_history (state->plugin->cls, + state->session, + &data->data.reserve->reserve. + pub, + &history); + GNUNET_assert (0 >= qs); + GNUNET_assert (NULL != history); + state->plugin->free_reserve_history (state->plugin->cls, + history); + } + break; - case PERF_TALER_EXCHANGEDB_CMD_GET_COIN_TRANSACTION: - { - unsigned int coin_index; - struct PERF_TALER_EXCHANGEDB_Coin *coin; - struct TALER_EXCHANGEDB_TransactionList *transactions; - enum GNUNET_DB_QueryStatus qs; - - coin_index = state->cmd[state->i].details.get_coin_transaction.index_coin; - coin = state->cmd[coin_index].exposed.data.coin; - qs = state->plugin->get_coin_transactions (state->plugin->cls, - state->session, - &coin->public_info.coin_pub, - GNUNET_YES, - &transactions); - GNUNET_assert (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qs); - GNUNET_assert (transactions != NULL); - state->plugin->free_coin_transaction_list (state->plugin->cls, - transactions); - } - break; + case PERF_TALER_EXCHANGEDB_CMD_CREATE_DENOMINATION: + { + struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *dki = + PERF_TALER_EXCHANGEDB_denomination_init (); + GNUNET_assert (NULL != dki); + state->cmd[state->i].exposed.data.dki = dki; + } + break; - case PERF_TALER_EXCHANGEDB_CMD_CREATE_REFRESH_SESSION: - { - struct TALER_EXCHANGEDB_RefreshSession refresh_session; - unsigned int coin_index; - struct PERF_TALER_EXCHANGEDB_Coin *coin; - - coin_index = state->cmd[state->i].details.create_refresh_session.index_coin; - coin = state->cmd[coin_index].exposed.data.coin; - - refresh_session.coin = coin->public_info; - GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK, - &refresh_session.coin_sig, - sizeof (refresh_session.coin_sig)); - GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_WEAK, - &refresh_session.rc.session_hash); - GNUNET_assert (GNUNET_OK == - TALER_string_to_amount (CURRENCY ":1.1", - &refresh_session.amount_with_fee)); - refresh_session.noreveal_index = 1; - GNUNET_assert (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == - state->plugin->ensure_coin_known (state->plugin->cls, - state->session, - &refresh_session.coin)); - GNUNET_assert (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == - state->plugin->insert_melt (state->plugin->cls, - state->session, - &refresh_session)); - state->cmd[state->i].exposed.data.rc = refresh_session.rc; - } - break; + case PERF_TALER_EXCHANGEDB_CMD_INSERT_DENOMINATION: + { + unsigned int denom_index; + enum GNUNET_DB_QueryStatus ret; + struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *dki; + + denom_index = + state->cmd[state->i].details.insert_denomination.index_denom; + dki = state->cmd[denom_index].exposed.data.dki; + ret = state->plugin->insert_denomination_info (state->plugin->cls, + state->session, + &dki->denom_pub, + &dki->issue); + GNUNET_assert (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == ret); + } + break; - case PERF_TALER_EXCHANGEDB_CMD_GET_REFRESH_SESSION: - { - unsigned int hash_index; - const struct TALER_RefreshCommitmentP *rc; - struct TALER_EXCHANGEDB_RefreshMelt refresh; - - hash_index = state->cmd[state->i].details.get_refresh_session.index_hash; - rc = &state->cmd[hash_index].exposed.data.rc; - state->plugin->get_melt (state->plugin->cls, - state->session, - rc, - &refresh); - } - break; + case PERF_TALER_EXCHANGEDB_CMD_GET_DENOMINATION: + { + unsigned int denom_index; + enum GNUNET_DB_QueryStatus qs; + struct PERF_TALER_EXCHANGEDB_Data *data; + struct GNUNET_HashCode hc; + + denom_index = state->cmd[state->i].details.get_denomination.index_denom; + data = &state->cmd[denom_index].exposed; + GNUNET_CRYPTO_rsa_public_key_hash ( + data->data.dki->denom_pub.rsa_public_key, + &hc); + qs = state->plugin->get_denomination_info (state->plugin->cls, + state->session, + &hc, + &data->data.dki->issue); + GNUNET_assert (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qs); + } + break; - case PERF_TALER_EXCHANGEDB_CMD_INSERT_REFRESH_REVEAL: - { - unsigned int hash_index; - unsigned int denom_index; - const struct TALER_RefreshCommitmentP *rc; - struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *denom; - struct TALER_TransferPublicKeyP tpub; - struct TALER_TransferPrivateKeyP tprivs[2]; - struct TALER_EXCHANGEDB_RefreshRevealedCoin rrc; - - hash_index = state->cmd[state->i].details.insert_refresh_reveal.index_hash; - denom_index = state->cmd[state->i].details.insert_refresh_reveal.index_denom; - rc = &state->cmd[hash_index].exposed.data.rc; - denom = state->cmd[denom_index].exposed.data.dki; - rrc.denom_pub = denom->denom_pub; - rrc.coin_ev = "coin_ev"; - rrc.coin_ev_size = strlen (rrc.coin_ev) + 1; - GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK, - &rrc.coin_sig, - sizeof (struct TALER_CoinSpendSignatureP)); - GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK, - tprivs, - sizeof (struct TALER_TransferPrivateKeyP) * 2); - GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK, - &tpub, - sizeof (struct TALER_TransferPublicKeyP)); - GNUNET_assert (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == - state->plugin->insert_refresh_reveal (state->plugin->cls, - state->session, - rc, - 1, - &rrc, - 2, - tprivs, - &tpub)); - } - break; + case PERF_TALER_EXCHANGEDB_CMD_CREATE_WITHDRAW: + { + unsigned int dki_index; + unsigned int reserve_index; + struct PERF_TALER_EXCHANGEDB_Coin *coin; + + dki_index = state->cmd[state->i].details.create_withdraw.index_dki; + reserve_index = + state->cmd[state->i].details.create_withdraw.index_reserve; + coin = PERF_TALER_EXCHANGEDB_coin_init ( + state->cmd[dki_index].exposed.data.dki, + state->cmd[reserve_index]. + exposed.data.reserve); + GNUNET_assert (NULL != coin); + state->cmd[state->i].exposed.data.coin = coin; + } + break; - case PERF_TALER_EXCHANGEDB_CMD_GET_REFRESH_REVEAL: - { - int hash_index; - const struct TALER_RefreshCommitmentP *rc; - - hash_index = state->cmd[state->i].details.get_refresh_reveal.index_hash; - rc = &state->cmd[hash_index].exposed.data.rc; - state->plugin->get_refresh_reveal (state->plugin->cls, - state->session, - rc, - &refresh_reveal_cb, - state); - } - break; + case PERF_TALER_EXCHANGEDB_CMD_INSERT_WITHDRAW: + { + unsigned int coin_index; + enum GNUNET_DB_QueryStatus qs; + struct PERF_TALER_EXCHANGEDB_Coin *coin; + + coin_index = state->cmd[state->i].details.insert_withdraw.index_coin; + coin = state->cmd[coin_index].exposed.data.coin; + qs = state->plugin->insert_withdraw_info (state->plugin->cls, + state->session, + &coin->blind); + GNUNET_assert (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qs); + } + break; + + case PERF_TALER_EXCHANGEDB_CMD_GET_WITHDRAW: + { + unsigned int source_index; + enum GNUNET_DB_QueryStatus qs; + struct PERF_TALER_EXCHANGEDB_Data *data; + + source_index = + state->cmd[state->i].details.get_denomination.index_denom; + data = &state->cmd[source_index].exposed; + qs = state->plugin->get_withdraw_info (state->plugin->cls, + state->session, + &data->data.coin->blind. + h_coin_envelope, + &data->data.coin->blind); + GNUNET_assert (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qs); + } + break; + + case PERF_TALER_EXCHANGEDB_CMD_GET_COIN_TRANSACTION: + { + unsigned int coin_index; + struct PERF_TALER_EXCHANGEDB_Coin *coin; + struct TALER_EXCHANGEDB_TransactionList *transactions; + enum GNUNET_DB_QueryStatus qs; + + coin_index = + state->cmd[state->i].details.get_coin_transaction.index_coin; + coin = state->cmd[coin_index].exposed.data.coin; + qs = state->plugin->get_coin_transactions (state->plugin->cls, + state->session, + &coin->public_info.coin_pub, + GNUNET_YES, + &transactions); + GNUNET_assert (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qs); + GNUNET_assert (transactions != NULL); + state->plugin->free_coin_transaction_list (state->plugin->cls, + transactions); + } + break; + + case PERF_TALER_EXCHANGEDB_CMD_CREATE_REFRESH_SESSION: + { + struct TALER_EXCHANGEDB_RefreshSession refresh_session; + unsigned int coin_index; + struct PERF_TALER_EXCHANGEDB_Coin *coin; + + coin_index = + state->cmd[state->i].details.create_refresh_session.index_coin; + coin = state->cmd[coin_index].exposed.data.coin; + + refresh_session.coin = coin->public_info; + GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK, + &refresh_session.coin_sig, + sizeof (refresh_session.coin_sig)); + GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_WEAK, + &refresh_session.rc.session_hash); + GNUNET_assert (GNUNET_OK == + TALER_string_to_amount (CURRENCY ":1.1", + &refresh_session.amount_with_fee)); + refresh_session.noreveal_index = 1; + GNUNET_assert (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == + state->plugin->ensure_coin_known (state->plugin->cls, + state->session, + &refresh_session.coin)); + GNUNET_assert (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == + state->plugin->insert_melt (state->plugin->cls, + state->session, + &refresh_session)); + state->cmd[state->i].exposed.data.rc = refresh_session.rc; + } + break; - case PERF_TALER_EXCHANGEDB_CMD_GET_LINK_DATA: - break; + case PERF_TALER_EXCHANGEDB_CMD_GET_REFRESH_SESSION: + { + unsigned int hash_index; + const struct TALER_RefreshCommitmentP *rc; + struct TALER_EXCHANGEDB_RefreshMelt refresh; + + hash_index = + state->cmd[state->i].details.get_refresh_session.index_hash; + rc = &state->cmd[hash_index].exposed.data.rc; + state->plugin->get_melt (state->plugin->cls, + state->session, + rc, + &refresh); + } + break; + + case PERF_TALER_EXCHANGEDB_CMD_INSERT_REFRESH_REVEAL: + { + unsigned int hash_index; + unsigned int denom_index; + const struct TALER_RefreshCommitmentP *rc; + struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *denom; + struct TALER_TransferPublicKeyP tpub; + struct TALER_TransferPrivateKeyP tprivs[2]; + struct TALER_EXCHANGEDB_RefreshRevealedCoin rrc; + + hash_index = + state->cmd[state->i].details.insert_refresh_reveal.index_hash; + denom_index = + state->cmd[state->i].details.insert_refresh_reveal.index_denom; + rc = &state->cmd[hash_index].exposed.data.rc; + denom = state->cmd[denom_index].exposed.data.dki; + rrc.denom_pub = denom->denom_pub; + rrc.coin_ev = "coin_ev"; + rrc.coin_ev_size = strlen (rrc.coin_ev) + 1; + GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK, + &rrc.coin_sig, + sizeof (struct TALER_CoinSpendSignatureP)); + GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK, + tprivs, + sizeof (struct TALER_TransferPrivateKeyP) + * 2); + GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK, + &tpub, + sizeof (struct TALER_TransferPublicKeyP)); + GNUNET_assert (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == + state->plugin->insert_refresh_reveal (state->plugin->cls, + state->session, + rc, + 1, + &rrc, + 2, + tprivs, + &tpub)); + } + break; + + case PERF_TALER_EXCHANGEDB_CMD_GET_REFRESH_REVEAL: + { + int hash_index; + const struct TALER_RefreshCommitmentP *rc; + + hash_index = state->cmd[state->i].details.get_refresh_reveal.index_hash; + rc = &state->cmd[hash_index].exposed.data.rc; + state->plugin->get_refresh_reveal (state->plugin->cls, + state->session, + rc, + &refresh_reveal_cb, + state); + } + break; + + case PERF_TALER_EXCHANGEDB_CMD_GET_LINK_DATA: + break; } } @@ -1579,80 +1606,80 @@ PERF_TALER_EXCHANGEDB_run_benchmark (const char *benchmark_name, struct TALER_EXCHANGEDB_Plugin *plugin; struct GNUNET_CONFIGURATION_Handle *config; int ret = 0; - struct PERF_TALER_EXCHANGEDB_Cmd init_def[] = - { + struct PERF_TALER_EXCHANGEDB_Cmd init_def[] = { // Denomination used to create coins PERF_TALER_EXCHANGEDB_INIT_CMD_DEBUG ("00 - Start of interpreter"), PERF_TALER_EXCHANGEDB_INIT_CMD_LOOP ("01 - denomination loop", - PERF_TALER_EXCHANGEDB_NB_DENOMINATION_INIT), + PERF_TALER_EXCHANGEDB_NB_DENOMINATION_INIT), PERF_TALER_EXCHANGEDB_INIT_CMD_START_TRANSACTION (""), PERF_TALER_EXCHANGEDB_INIT_CMD_CREATE_DENOMINATION ("01 - denomination"), PERF_TALER_EXCHANGEDB_INIT_CMD_INSERT_DENOMINATION ("01 - insert", - "01 - denomination"), + "01 - denomination"), PERF_TALER_EXCHANGEDB_INIT_CMD_COMMIT_TRANSACTION (""), PERF_TALER_EXCHANGEDB_INIT_CMD_SAVE_ARRAY ("01 - save denomination", - "01 - denomination loop", - "01 - denomination", - PERF_TALER_EXCHANGEDB_NB_DENOMINATION_SAVE), + "01 - denomination loop", + "01 - denomination", + PERF_TALER_EXCHANGEDB_NB_DENOMINATION_SAVE), PERF_TALER_EXCHANGEDB_INIT_CMD_END_LOOP ("", - "01 - denomination loop"), + "01 - denomination loop"), PERF_TALER_EXCHANGEDB_INIT_CMD_DEBUG ("01 - init denomination complete"), // End of initialization // Reserve initialization PERF_TALER_EXCHANGEDB_INIT_CMD_LOOP ("02 - init reserve loop", - PERF_TALER_EXCHANGEDB_NB_RESERVE_INIT), + PERF_TALER_EXCHANGEDB_NB_RESERVE_INIT), PERF_TALER_EXCHANGEDB_INIT_CMD_CREATE_RESERVE ("02 - reserve"), PERF_TALER_EXCHANGEDB_INIT_CMD_INSERT_RESERVE ("02 - insert", - "02 - reserve"), + "02 - reserve"), PERF_TALER_EXCHANGEDB_INIT_CMD_SAVE_ARRAY ("02 - save reserve", - "02 - init reserve loop", - "02 - reserve", - PERF_TALER_EXCHANGEDB_NB_RESERVE_SAVE), + "02 - init reserve loop", + "02 - reserve", + PERF_TALER_EXCHANGEDB_NB_RESERVE_SAVE), PERF_TALER_EXCHANGEDB_INIT_CMD_END_LOOP ("", - "02 - init reserve loop"), + "02 - init reserve loop"), PERF_TALER_EXCHANGEDB_INIT_CMD_DEBUG ("02 - reserve init complete"), // End reserve init // Withdrawal initialization PERF_TALER_EXCHANGEDB_INIT_CMD_LOOP ("03 - init withdraw loop", - PERF_TALER_EXCHANGEDB_NB_WITHDRAW_INIT), + PERF_TALER_EXCHANGEDB_NB_WITHDRAW_INIT), PERF_TALER_EXCHANGEDB_INIT_CMD_START_TRANSACTION (""), PERF_TALER_EXCHANGEDB_INIT_CMD_LOAD_ARRAY ("03 - denomination load", - "03 - init withdraw loop", - "01 - save denomination"), + "03 - init withdraw loop", + "01 - save denomination"), PERF_TALER_EXCHANGEDB_INIT_CMD_LOAD_ARRAY ("03 - reserve load", - "03 - init withdraw loop", - "02 - save reserve"), + "03 - init withdraw loop", + "02 - save reserve"), PERF_TALER_EXCHANGEDB_INIT_CMD_CREATE_WITHDRAW ("03 - withdraw", - "03 - denomination load", - "03 - reserve load"), + "03 - denomination load", + "03 - reserve load"), PERF_TALER_EXCHANGEDB_INIT_CMD_INSERT_WITHDRAW ("03 - insert", - "03 - withdraw"), + "03 - withdraw"), PERF_TALER_EXCHANGEDB_INIT_CMD_COMMIT_TRANSACTION (""), PERF_TALER_EXCHANGEDB_INIT_CMD_SAVE_ARRAY ("03 - save coin", - "03 - init withdraw loop", - "03 - withdraw", - PERF_TALER_EXCHANGEDB_NB_WITHDRAW_SAVE), + "03 - init withdraw loop", + "03 - withdraw", + PERF_TALER_EXCHANGEDB_NB_WITHDRAW_SAVE), PERF_TALER_EXCHANGEDB_INIT_CMD_END_LOOP ("", - "03 - init withdraw loop"), + "03 - init withdraw loop"), PERF_TALER_EXCHANGEDB_INIT_CMD_DEBUG ("03 - withdraw init complete"), - //End of withdrawal initialization - //Deposit initialization + // End of withdrawal initialization + // Deposit initialization PERF_TALER_EXCHANGEDB_INIT_CMD_LOOP ("04 - deposit init loop", - PERF_TALER_EXCHANGEDB_NB_DEPOSIT_INIT), + PERF_TALER_EXCHANGEDB_NB_DEPOSIT_INIT), PERF_TALER_EXCHANGEDB_INIT_CMD_START_TRANSACTION ("04 - start transaction"), PERF_TALER_EXCHANGEDB_INIT_CMD_LOAD_ARRAY ("04 - denomination load", - "04 - deposit init loop", - "03 - save coin"), + "04 - deposit init loop", + "03 - save coin"), PERF_TALER_EXCHANGEDB_INIT_CMD_INSERT_DEPOSIT ("04 - deposit", - "04 - denomination load"), - PERF_TALER_EXCHANGEDB_INIT_CMD_COMMIT_TRANSACTION ("04 - commit transaction"), + "04 - denomination load"), + PERF_TALER_EXCHANGEDB_INIT_CMD_COMMIT_TRANSACTION ( + "04 - commit transaction"), PERF_TALER_EXCHANGEDB_INIT_CMD_SAVE_ARRAY ("04 - deposit array", - "04 - deposit init loop", - "04 - deposit", - PERF_TALER_EXCHANGEDB_NB_DEPOSIT_SAVE), + "04 - deposit init loop", + "04 - deposit", + PERF_TALER_EXCHANGEDB_NB_DEPOSIT_SAVE), PERF_TALER_EXCHANGEDB_INIT_CMD_END_LOOP ("04 - deposit init loop end", - "04 - deposit init loop"), + "04 - deposit init loop"), PERF_TALER_EXCHANGEDB_INIT_CMD_DEBUG ("04 - deposit init complete"), // End of deposit initialization PERF_TALER_EXCHANGEDB_INIT_CMD_END ("end") @@ -1703,7 +1730,7 @@ PERF_TALER_EXCHANGEDB_run_benchmark (const char *benchmark_name, * Running the benchmark */ ret = PERF_TALER_EXCHANGEDB_interpret (plugin, - benchmark); + benchmark); if (GNUNET_OK != ret) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, diff --git a/src/exchangedb/perf_taler_exchangedb_interpreter.h b/src/exchangedb/perf_taler_exchangedb_interpreter.h index 60e676069..414e33fe0 100644 --- a/src/exchangedb/perf_taler_exchangedb_interpreter.h +++ b/src/exchangedb/perf_taler_exchangedb_interpreter.h @@ -53,11 +53,11 @@ * @param _label The label of the command */ #define PERF_TALER_EXCHANGEDB_INIT_CMD_END(_label) \ -{ \ - .command = PERF_TALER_EXCHANGEDB_CMD_END, \ - .label = _label, \ - .exposed.type = PERF_TALER_EXCHANGEDB_NONE \ -} + { \ + .command = PERF_TALER_EXCHANGEDB_CMD_END, \ + .label = _label, \ + .exposed.type = PERF_TALER_EXCHANGEDB_NONE \ + } /** @@ -67,11 +67,11 @@ * will be logged each time the command runs */ #define PERF_TALER_EXCHANGEDB_INIT_CMD_DEBUG(_label) \ -{ \ - .command = PERF_TALER_EXCHANGEDB_CMD_DEBUG, \ - .label = _label, \ - .exposed.type = PERF_TALER_EXCHANGEDB_NONE \ -} + { \ + .command = PERF_TALER_EXCHANGEDB_CMD_DEBUG, \ + .label = _label, \ + .exposed.type = PERF_TALER_EXCHANGEDB_NONE \ + } /** * The begining of a loop @@ -80,14 +80,14 @@ * @param _iter the number of iterations of the loop */ #define PERF_TALER_EXCHANGEDB_INIT_CMD_LOOP(_label, _iter) \ -{ \ - .command = PERF_TALER_EXCHANGEDB_CMD_LOOP , \ - .label = _label , \ - .exposed.type = PERF_TALER_EXCHANGEDB_NONE , \ - .details.loop = { \ - .max_iterations = _iter , \ - .curr_iteration = 0 } \ -} + { \ + .command = PERF_TALER_EXCHANGEDB_CMD_LOOP, \ + .label = _label, \ + .exposed.type = PERF_TALER_EXCHANGEDB_NONE, \ + .details.loop = { \ + .max_iterations = _iter, \ + .curr_iteration = 0 } \ + } /** * Marks the end of the loop @_label_loop @@ -96,12 +96,12 @@ * @param _label_loop the label of the loop closed by this command */ #define PERF_TALER_EXCHANGEDB_INIT_CMD_END_LOOP(_label, _label_loop) \ -{\ - .command = PERF_TALER_EXCHANGEDB_CMD_END_LOOP , \ - .label = _label , \ - .exposed.type = PERF_TALER_EXCHANGEDB_NONE , \ - .details.end_loop.label_loop = _label_loop \ -} + { \ + .command = PERF_TALER_EXCHANGEDB_CMD_END_LOOP, \ + .label = _label, \ + .exposed.type = PERF_TALER_EXCHANGEDB_NONE, \ + .details.end_loop.label_loop = _label_loop \ + } /** * Saves the time of execution to use for logging with Gauger @@ -109,11 +109,11 @@ * @param _label the label of the command */ #define PERF_TALER_EXCHANGEDB_INIT_CMD_GET_TIME(_label) \ -{ \ - .command = PERF_TALER_EXCHANGEDB_CMD_GET_TIME, \ - .label = _label, \ - .exposed.type = PERF_TALER_EXCHANGEDB_TIME \ -} + { \ + .command = PERF_TALER_EXCHANGEDB_CMD_GET_TIME, \ + .label = _label, \ + .exposed.type = PERF_TALER_EXCHANGEDB_TIME \ + } /** * Commits the duration between @a _label_start and @a _label_stop @@ -126,20 +126,22 @@ * @param _unit the unit of the data measured, typicly something/sec * @param _divide number of measurments in the interval */ -#define PERF_TALER_EXCHANGEDB_INIT_CMD_GAUGER(_label, _label_start, _label_stop, _category, _description, _unit, _divide) \ -{ \ - .command = PERF_TALER_EXCHANGEDB_CMD_GAUGER, \ - .label = _label, \ - .exposed.type = PERF_TALER_EXCHANGEDB_NONE, \ - .details.gauger = { \ - .label_start = _label_start, \ - .label_stop = _label_stop, \ - .category = _category, \ - .description = _description, \ - .unit = _unit, \ - .divide = _divide, \ - } \ -} +#define PERF_TALER_EXCHANGEDB_INIT_CMD_GAUGER(_label, _label_start, _label_stop, \ + _category, _description, _unit, \ + _divide) \ + { \ + .command = PERF_TALER_EXCHANGEDB_CMD_GAUGER, \ + .label = _label, \ + .exposed.type = PERF_TALER_EXCHANGEDB_NONE, \ + .details.gauger = { \ + .label_start = _label_start, \ + .label_stop = _label_stop, \ + .category = _category, \ + .description = _description, \ + .unit = _unit, \ + .divide = _divide, \ + } \ + } /** * Initiate a database transaction @@ -147,11 +149,11 @@ * @param _label the label of the command */ #define PERF_TALER_EXCHANGEDB_INIT_CMD_START_TRANSACTION(_label) \ -{ \ - .command = PERF_TALER_EXCHANGEDB_CMD_START_TRANSACTION, \ - .label = _label, \ - .exposed.type = PERF_TALER_EXCHANGEDB_NONE, \ -} + { \ + .command = PERF_TALER_EXCHANGEDB_CMD_START_TRANSACTION, \ + .label = _label, \ + .exposed.type = PERF_TALER_EXCHANGEDB_NONE, \ + } /** * Commits a database transaction @@ -159,11 +161,11 @@ * @param _label the label of the command */ #define PERF_TALER_EXCHANGEDB_INIT_CMD_COMMIT_TRANSACTION(_label) \ -{ \ - .command = PERF_TALER_EXCHANGEDB_CMD_COMMIT_TRANSACTION, \ - .label = _label, \ - .exposed.type = PERF_TALER_EXCHANGEDB_NONE, \ -} + { \ + .command = PERF_TALER_EXCHANGEDB_CMD_COMMIT_TRANSACTION, \ + .label = _label, \ + .exposed.type = PERF_TALER_EXCHANGEDB_NONE, \ + } /** * Abort the current transaction @@ -171,9 +173,9 @@ * @param _label the label of the command */ #define PERF_TALER_EXCHANGEDB_INIT_CMD_ABORT_TRANSACTION(_label) \ -{ \ - .command = PERF_TALER_EXCHANGEDB_CMD_ABORT_TRANSACTION, \ - .label = _label, + { \ + .command = PERF_TALER_EXCHANGEDB_CMD_ABORT_TRANSACTION, \ + .label = _label, /** * Saves randomly selected items from @a _label_save @@ -184,17 +186,18 @@ * @param _label_save the label of the command which outout is saved by this command * @param _nb_saved the total number of items to be saved */ -#define PERF_TALER_EXCHANGEDB_INIT_CMD_SAVE_ARRAY(_label, _label_loop, _label_save, _nb_saved) \ -{ \ - .command = PERF_TALER_EXCHANGEDB_CMD_SAVE_ARRAY, \ - .label = _label, \ - .exposed.type = PERF_TALER_EXCHANGEDB_NONE, \ - .details.save_array = { \ - .label_loop = _label_loop, \ - .label_save = _label_save, \ - .nb_saved = _nb_saved, \ - } \ -} +#define PERF_TALER_EXCHANGEDB_INIT_CMD_SAVE_ARRAY(_label, _label_loop, \ + _label_save, _nb_saved) \ + { \ + .command = PERF_TALER_EXCHANGEDB_CMD_SAVE_ARRAY, \ + .label = _label, \ + .exposed.type = PERF_TALER_EXCHANGEDB_NONE, \ + .details.save_array = { \ + .label_loop = _label_loop, \ + .label_save = _label_save, \ + .nb_saved = _nb_saved, \ + } \ + } /** * Loads data from a #PERF_TALER_EXCHANGEDB_CMD_SAVE_ARRAY to allow other @@ -204,16 +207,17 @@ * @param _label_loop the label of the loop to iterate over * @param _label_save the label of the #PERF_TALER_EXCHANGEDB_CMD_SAVE_ARRAY providing data */ -#define PERF_TALER_EXCHANGEDB_INIT_CMD_LOAD_ARRAY(_label, _label_loop, _label_save) \ -{ \ - .command = PERF_TALER_EXCHANGEDB_CMD_LOAD_ARRAY, \ - .label = _label, \ - .exposed.type = PERF_TALER_EXCHANGEDB_NONE, \ - .details.load_array = { \ - .label_loop = _label_loop, \ - .label_save = _label_save \ - } \ -} +#define PERF_TALER_EXCHANGEDB_INIT_CMD_LOAD_ARRAY(_label, _label_loop, \ + _label_save) \ + { \ + .command = PERF_TALER_EXCHANGEDB_CMD_LOAD_ARRAY, \ + .label = _label, \ + .exposed.type = PERF_TALER_EXCHANGEDB_NONE, \ + .details.load_array = { \ + .label_loop = _label_loop, \ + .label_save = _label_save \ + } \ + } /** * Create a denomination key to use @@ -223,11 +227,11 @@ * @param _label the label of this command */ #define PERF_TALER_EXCHANGEDB_INIT_CMD_CREATE_DENOMINATION(_label) \ -{ \ - .command = PERF_TALER_EXCHANGEDB_CMD_CREATE_DENOMINATION, \ - .label = _label, \ - .exposed.type = PERF_TALER_EXCHANGEDB_DENOMINATION_INFO, \ -} + { \ + .command = PERF_TALER_EXCHANGEDB_CMD_CREATE_DENOMINATION, \ + .label = _label, \ + .exposed.type = PERF_TALER_EXCHANGEDB_DENOMINATION_INFO, \ + } /** * Inserts informations about a denomination key in the database @@ -236,12 +240,12 @@ * @param _label_denom the label of the denomination to insert */ #define PERF_TALER_EXCHANGEDB_INIT_CMD_INSERT_DENOMINATION(_label, _label_denom) \ -{ \ - .command = PERF_TALER_EXCHANGEDB_CMD_INSERT_DENOMINATION, \ - .label = _label, \ - .exposed.type = PERF_TALER_EXCHANGEDB_NONE, \ - .details.insert_denomination.label_denom = _label_denom, \ -} + { \ + .command = PERF_TALER_EXCHANGEDB_CMD_INSERT_DENOMINATION, \ + .label = _label, \ + .exposed.type = PERF_TALER_EXCHANGEDB_NONE, \ + .details.insert_denomination.label_denom = _label_denom, \ + } /** * Polls the database about informations regarding a specific denomination key @@ -250,12 +254,12 @@ * @param _label_denom the label of the command providing information about the denomination key */ #define PERF_TALER_EXCHANGEDB_INIT_CMD_GET_DENOMINATION(_label, _label_denom) \ -{ \ - .command = PERF_TALER_EXCHANGEDB_CMD_GET_DENOMINATION, \ - .label = _label, \ - .exposed.type = PERF_TALER_EXCHANGEDB_NONE, \ - .details.get_denomination.label_denom = _label_denom \ -} + { \ + .command = PERF_TALER_EXCHANGEDB_CMD_GET_DENOMINATION, \ + .label = _label, \ + .exposed.type = PERF_TALER_EXCHANGEDB_NONE, \ + .details.get_denomination.label_denom = _label_denom \ + } /** * Create a reserve to be used later @@ -264,11 +268,11 @@ * @param _label the label of the command */ #define PERF_TALER_EXCHANGEDB_INIT_CMD_CREATE_RESERVE(_label) \ -{ \ - .command = PERF_TALER_EXCHANGEDB_CMD_CREATE_RESERVE, \ - .label = _label, \ - .exposed.type = PERF_TALER_EXCHANGEDB_RESERVE \ -} + { \ + .command = PERF_TALER_EXCHANGEDB_CMD_CREATE_RESERVE, \ + .label = _label, \ + .exposed.type = PERF_TALER_EXCHANGEDB_RESERVE \ + } /** * Insert a new reserve in the database containing 1000 Euros @@ -277,12 +281,12 @@ * @param _label_reserve the label of the reserve to insert */ #define PERF_TALER_EXCHANGEDB_INIT_CMD_INSERT_RESERVE(_label, _label_reserve) \ -{ \ - .command = PERF_TALER_EXCHANGEDB_CMD_INSERT_RESERVE, \ - .label = _label, \ - .exposed.type = PERF_TALER_EXCHANGEDB_NONE, \ - .details.insert_reserve.label_reserve = _label_reserve \ -} + { \ + .command = PERF_TALER_EXCHANGEDB_CMD_INSERT_RESERVE, \ + .label = _label, \ + .exposed.type = PERF_TALER_EXCHANGEDB_NONE, \ + .details.insert_reserve.label_reserve = _label_reserve \ + } /** * Polls the database for a secific reserve's details @@ -291,12 +295,12 @@ * @param _label_reserve the reserve to poll */ #define PERF_TALER_EXCHANGEDB_INIT_CMD_GET_RESERVE(_label, _label_reserve) \ -{ \ - .command = PERF_TALER_EXCHANGEDB_CMD_GET_RESERVE, \ - .label = _label, \ - .exposed.type = PERF_TALER_EXCHANGEDB_NONE, \ - .details.get_reserve.label_reserve = _label_reserve \ -} + { \ + .command = PERF_TALER_EXCHANGEDB_CMD_GET_RESERVE, \ + .label = _label, \ + .exposed.type = PERF_TALER_EXCHANGEDB_NONE, \ + .details.get_reserve.label_reserve = _label_reserve \ + } /** * Polls the database for the history of a reserve @@ -304,13 +308,14 @@ * @param _label the label of the command * @param _label_reserve the reserve to examine */ -#define PERF_TALER_EXCHANGEDB_INIT_CMD_GET_RESERVE_HISTORY(_label, _label_reserve) \ -{ \ - .command = PERF_TALER_EXCHANGEDB_CMD_GET_RESERVE_HISTORY, \ - .label = _label, \ - .exposed.type = PERF_TALER_EXCHANGEDB_NONE, \ - .details.get_reserve_history.label_reserve = _label_reserve \ -} +#define PERF_TALER_EXCHANGEDB_INIT_CMD_GET_RESERVE_HISTORY(_label, \ + _label_reserve) \ + { \ + .command = PERF_TALER_EXCHANGEDB_CMD_GET_RESERVE_HISTORY, \ + .label = _label, \ + .exposed.type = PERF_TALER_EXCHANGEDB_NONE, \ + .details.get_reserve_history.label_reserve = _label_reserve \ + } /** * Creates a coin to be used later @@ -319,16 +324,17 @@ * @param _label_dki denomination key used to sign the coin * @param _label_reserve reserve used to emmit the coin */ -#define PERF_TALER_EXCHANGEDB_INIT_CMD_CREATE_WITHDRAW(_label, _label_dki, _label_reserve) \ -{ \ - .command = PERF_TALER_EXCHANGEDB_CMD_CREATE_WITHDRAW, \ - .label = _label, \ - .exposed.type = PERF_TALER_EXCHANGEDB_COIN, \ - .details.create_withdraw = {\ - .label_dki = _label_dki, \ - .label_reserve = _label_reserve, \ - } \ -} +#define PERF_TALER_EXCHANGEDB_INIT_CMD_CREATE_WITHDRAW(_label, _label_dki, \ + _label_reserve) \ + { \ + .command = PERF_TALER_EXCHANGEDB_CMD_CREATE_WITHDRAW, \ + .label = _label, \ + .exposed.type = PERF_TALER_EXCHANGEDB_COIN, \ + .details.create_withdraw = { \ + .label_dki = _label_dki, \ + .label_reserve = _label_reserve, \ + } \ + } /** * Inserts information about a withdrawal into the database @@ -339,12 +345,12 @@ * @param _label_coin the coin to insert */ #define PERF_TALER_EXCHANGEDB_INIT_CMD_INSERT_WITHDRAW(_label, _label_coin) \ -{ \ - .command = PERF_TALER_EXCHANGEDB_CMD_INSERT_WITHDRAW, \ - .label = _label, \ - .exposed.type = PERF_TALER_EXCHANGEDB_NONE, \ - .details.insert_withdraw.label_coin = _label_coin\ -} + { \ + .command = PERF_TALER_EXCHANGEDB_CMD_INSERT_WITHDRAW, \ + .label = _label, \ + .exposed.type = PERF_TALER_EXCHANGEDB_NONE, \ + .details.insert_withdraw.label_coin = _label_coin \ + } /** @@ -354,12 +360,12 @@ * @param _label_coin the coin to check */ #define PERF_TALER_EXCHANGEDB_INIT_CMD_GET_WITHDRAW(_label, _label_coin) \ -{ \ - .command = PERF_TALER_EXCHANGEDB_CMD_GET_WITHDRAW, \ - .label = _label, \ - .exposed.type = PERF_TALER_EXCHANGEDB_NONE, \ - .details.get_withdraw.label_coin = _label_coin, \ -} + { \ + .command = PERF_TALER_EXCHANGEDB_CMD_GET_WITHDRAW, \ + .label = _label, \ + .exposed.type = PERF_TALER_EXCHANGEDB_NONE, \ + .details.get_withdraw.label_coin = _label_coin, \ + } /** @@ -371,16 +377,17 @@ * @param _label_dki the denomination of the created coin * @param _label_reserve the reserve used to provide currency */ -#define PERF_TALER_EXCHANGEDB_INIT_CMD_WITHDRAW_SIGN(_label, _label_dki, _label_reserve) \ +#define PERF_TALER_EXCHANGEDB_INIT_CMD_WITHDRAW_SIGN(_label, _label_dki, \ + _label_reserve) \ PERF_TALER_EXCHANGEDB_INIT_CMD_CREATE_WITHDRAW (_label "withdraw", \ - _label_dki, \ - _label_reserve), \ - PERF_TALER_EXCHANGEDB_INIT_CMD_GET_DENOMINATION(_label "withdraw info", \ - _label_dki), \ - PERF_TALER_EXCHANGEDB_INIT_CMD_GET_RESERVE_HISTORY(_label "reserve_history", \ - _label_reserve), \ - PERF_TALER_EXCHANGEDB_INIT_CMD_INSERT_WITHDRAW(_label "insert withdraw", \ - _label "withdraw") + _label_dki, \ + _label_reserve), \ + PERF_TALER_EXCHANGEDB_INIT_CMD_GET_DENOMINATION (_label "withdraw info", \ + _label_dki), \ + PERF_TALER_EXCHANGEDB_INIT_CMD_GET_RESERVE_HISTORY (_label "reserve_history", \ + _label_reserve), \ + PERF_TALER_EXCHANGEDB_INIT_CMD_INSERT_WITHDRAW (_label "insert withdraw", \ + _label "withdraw") /** * Create a deposit for use later @@ -390,12 +397,12 @@ * @param _label_coin the coin used to pay */ #define PERF_TALER_EXCHANGEDB_INIT_CMD_CREATE_DEPOSIT(_label, _label_coin) \ -{ \ - .command = PERF_TALER_EXCHANGEDB_CMD_CREATE_DEPOSIT, \ - .label = _label, \ - .exposed.type = PERF_TALER_EXCHANGEDB_DEPOSIT, \ - .details.create_deposit.label_coin = _label_coin, \ -} + { \ + .command = PERF_TALER_EXCHANGEDB_CMD_CREATE_DEPOSIT, \ + .label = _label, \ + .exposed.type = PERF_TALER_EXCHANGEDB_DEPOSIT, \ + .details.create_deposit.label_coin = _label_coin, \ + } /** * Insert a deposit into the database @@ -404,12 +411,12 @@ * @param _label_deposit the deposit inseerted */ #define PERF_TALER_EXCHANGEDB_INIT_CMD_INSERT_DEPOSIT(_label, _label_deposit) \ -{ \ - .command = PERF_TALER_EXCHANGEDB_CMD_INSERT_DEPOSIT,\ - .label = _label, \ - .exposed.type = PERF_TALER_EXCHANGEDB_NONE, \ - .details.insert_deposit.label_deposit = _label_deposit, \ -} + { \ + .command = PERF_TALER_EXCHANGEDB_CMD_INSERT_DEPOSIT, \ + .label = _label, \ + .exposed.type = PERF_TALER_EXCHANGEDB_NONE, \ + .details.insert_deposit.label_deposit = _label_deposit, \ + } /** * Check if a deposit is in the database @@ -418,12 +425,12 @@ * @param _label_deposit the deposit to use */ #define PERF_TALER_EXCHANGEDB_INIT_CMD_GET_DEPOSIT(_label, _label_deposit) \ -{ \ - .command = PERF_TALER_EXCHANGEDB_CMD_GET_DEPOSIT, \ - .label = _label, \ - .exposed.type = PERF_TALER_EXCHANGEDB_NONE, \ - .details.get_deposit.label_deposit = _label_deposit \ -} + { \ + .command = PERF_TALER_EXCHANGEDB_CMD_GET_DEPOSIT, \ + .label = _label, \ + .exposed.type = PERF_TALER_EXCHANGEDB_NONE, \ + .details.get_deposit.label_deposit = _label_deposit \ + } /** * Access the transaction history of a coin @@ -432,12 +439,12 @@ * @param _label_coin the coin which history is checked */ #define PERF_TALER_EXCHANGEDB_INIT_CMD_GET_COIN_TRANSACTION(_label, _label_coin) \ -{ \ - .command = PERF_TALER_EXCHANGEDB_CMD_GET_COIN_TRANSACTION, \ - .label = _label, \ - .exposed.type = PERF_TALER_EXCHANGEDB_NONE, \ - .details.get_coin_transaction.label_coin = _label_coin \ -} + { \ + .command = PERF_TALER_EXCHANGEDB_CMD_GET_COIN_TRANSACTION, \ + .label = _label, \ + .exposed.type = PERF_TALER_EXCHANGEDB_NONE, \ + .details.get_coin_transaction.label_coin = _label_coin \ + } /** * The /deposit api call @@ -447,11 +454,11 @@ */ #define PERF_TALER_EXCHANGEDB_INIT_CMD_DEPOSIT(_label, _label_coin) \ PERF_TALER_EXCHANGEDB_INIT_CMD_GET_COIN_TRANSACTION (_label "coin history", \ - _label_coin), \ + _label_coin), \ PERF_TALER_EXCHANGEDB_INIT_CMD_CREATE_DEPOSIT (_label "deposit", \ - _label_coin), \ + _label_coin), \ PERF_TALER_EXCHANGEDB_INIT_CMD_INSERT_DEPOSIT (_label "insert", \ - _label "deposit") + _label "deposit") /** * Insert informations about a refresh session @@ -459,13 +466,14 @@ * * @param _label the label of the command */ -#define PERF_TALER_EXCHANGEDB_INIT_CMD_CREATE_REFRESH_SESSION(_label, _label_coin) \ -{ \ - .command = PERF_TALER_EXCHANGEDB_CMD_CREATE_REFRESH_SESSION, \ - .label = _label, \ - .details.create_refresh_session.label_coin = _label_coin, \ - .exposed.type = PERF_TALER_EXCHANGEDB_REFRESH_HASH \ -} +#define PERF_TALER_EXCHANGEDB_INIT_CMD_CREATE_REFRESH_SESSION(_label, \ + _label_coin) \ + { \ + .command = PERF_TALER_EXCHANGEDB_CMD_CREATE_REFRESH_SESSION, \ + .label = _label, \ + .details.create_refresh_session.label_coin = _label_coin, \ + .exposed.type = PERF_TALER_EXCHANGEDB_REFRESH_HASH \ + } /** * Get informations about a refresh session @@ -474,12 +482,12 @@ * @param _label_hash the label of the hash to search */ #define PERF_TALER_EXCHANGEDB_INIT_CMD_GET_REFRESH_SESSION(_label, \ - _label_hash) \ -{ \ - .command = PERF_TALER_EXCHANGEDB_CMD_GET_REFRESH_SESSION, \ - .label = _label, \ - .exposed.type = PERF_TALER_EXCHANGEDB_NONE \ -} + _label_hash) \ + { \ + .command = PERF_TALER_EXCHANGEDB_CMD_GET_REFRESH_SESSION, \ + .label = _label, \ + .exposed.type = PERF_TALER_EXCHANGEDB_NONE \ + } /** @@ -995,9 +1003,9 @@ union PERF_TALER_EXCHANGEDB_CMD_Details unsigned int index_deposit; } get_deposit; - /** - * Data requiered for the #PERF_TALER_EXCHANGEDB_CMD_CREATE_REFRESH_SESSION command - */ + /** + * Data requiered for the #PERF_TALER_EXCHANGEDB_CMD_CREATE_REFRESH_SESSION command + */ struct PERF_TALER_EXCHANGEDB_CMD_createRefreshSessionDetails { /** @@ -1007,9 +1015,9 @@ union PERF_TALER_EXCHANGEDB_CMD_Details unsigned int index_coin; } create_refresh_session; - /** - * Data requiered for the #PERF_TALER_EXCHANGEDB_CMD_GET_REFRESH_SESSION command - */ + /** + * Data requiered for the #PERF_TALER_EXCHANGEDB_CMD_GET_REFRESH_SESSION command + */ struct PERF_TALER_EXCHANGEDB_CMD_getRefreshSessionDetails { /** @@ -1024,17 +1032,17 @@ union PERF_TALER_EXCHANGEDB_CMD_Details */ struct PERF_TALER_EXCHANGEDB_CMD_insertRefreshRevealDetails { - /** - * The refresh session hash - */ - const char *label_hash; + /** + * The refresh session hash + */ + const char *label_hash; unsigned int index_hash; - /** - * The new coin denomination - */ - const char *label_denom; - unsigned int index_denom; + /** + * The new coin denomination + */ + const char *label_denom; + unsigned int index_denom; } insert_refresh_reveal; /** @@ -1119,8 +1127,8 @@ PERF_TALER_EXCHANGEDB_run_benchmark (const char *benchmark_name, * @param cmd the commands to run */ int -PERF_TALER_EXCHANGEDB_interpret(struct TALER_EXCHANGEDB_Plugin *db_plugin, - struct PERF_TALER_EXCHANGEDB_Cmd cmd[]); +PERF_TALER_EXCHANGEDB_interpret (struct TALER_EXCHANGEDB_Plugin *db_plugin, + struct PERF_TALER_EXCHANGEDB_Cmd cmd[]); /** diff --git a/src/exchangedb/plugin_exchangedb_common.c b/src/exchangedb/plugin_exchangedb_common.c index 4c381586b..271421795 100644 --- a/src/exchangedb/plugin_exchangedb_common.c +++ b/src/exchangedb/plugin_exchangedb_common.c @@ -38,7 +38,7 @@ common_free_reserve_history (void *cls, while (NULL != rh) { - switch(rh->type) + switch (rh->type) { case TALER_EXCHANGEDB_RO_BANK_TO_EXCHANGE: bt = rh->details.bank; @@ -91,32 +91,38 @@ common_free_coin_transaction_list (void *cls, if (NULL != list->details.deposit->receiver_wire_account) json_decref (list->details.deposit->receiver_wire_account); if (NULL != list->details.deposit->coin.denom_sig.rsa_signature) - GNUNET_CRYPTO_rsa_signature_free (list->details.deposit->coin.denom_sig.rsa_signature); + GNUNET_CRYPTO_rsa_signature_free ( + list->details.deposit->coin.denom_sig.rsa_signature); GNUNET_free (list->details.deposit); break; case TALER_EXCHANGEDB_TT_REFRESH_MELT: if (NULL != list->details.melt->session.coin.denom_sig.rsa_signature) - GNUNET_CRYPTO_rsa_signature_free (list->details.melt->session.coin.denom_sig.rsa_signature); + GNUNET_CRYPTO_rsa_signature_free ( + list->details.melt->session.coin.denom_sig.rsa_signature); GNUNET_free (list->details.melt); break; case TALER_EXCHANGEDB_TT_OLD_COIN_PAYBACK: if (NULL != list->details.payback_refresh->coin.denom_sig.rsa_signature) - GNUNET_CRYPTO_rsa_signature_free (list->details.payback_refresh->coin.denom_sig.rsa_signature); + GNUNET_CRYPTO_rsa_signature_free ( + list->details.payback_refresh->coin.denom_sig.rsa_signature); GNUNET_free (list->details.old_coin_payback); break; case TALER_EXCHANGEDB_TT_REFUND: if (NULL != list->details.refund->coin.denom_sig.rsa_signature) - GNUNET_CRYPTO_rsa_signature_free (list->details.refund->coin.denom_sig.rsa_signature); + GNUNET_CRYPTO_rsa_signature_free ( + list->details.refund->coin.denom_sig.rsa_signature); GNUNET_free (list->details.refund); break; case TALER_EXCHANGEDB_TT_PAYBACK: if (NULL != list->details.payback->coin.denom_sig.rsa_signature) - GNUNET_CRYPTO_rsa_signature_free (list->details.payback->coin.denom_sig.rsa_signature); + GNUNET_CRYPTO_rsa_signature_free ( + list->details.payback->coin.denom_sig.rsa_signature); GNUNET_free (list->details.payback); break; case TALER_EXCHANGEDB_TT_PAYBACK_REFRESH: if (NULL != list->details.payback_refresh->coin.denom_sig.rsa_signature) - GNUNET_CRYPTO_rsa_signature_free (list->details.payback_refresh->coin.denom_sig.rsa_signature); + GNUNET_CRYPTO_rsa_signature_free ( + list->details.payback_refresh->coin.denom_sig.rsa_signature); GNUNET_free (list->details.payback_refresh); break; } diff --git a/src/exchangedb/plugin_exchangedb_postgres.c b/src/exchangedb/plugin_exchangedb_postgres.c index 2d4e0889f..75d124ce1 100644 --- a/src/exchangedb/plugin_exchangedb_postgres.c +++ b/src/exchangedb/plugin_exchangedb_postgres.c @@ -45,7 +45,8 @@ * @param field name of the database field to fetch amount from * @param amountp[out] pointer to amount to set */ -#define TALER_PQ_RESULT_SPEC_AMOUNT(field,amountp) TALER_PQ_result_spec_amount(field,pg->currency,amountp) +#define TALER_PQ_RESULT_SPEC_AMOUNT(field,amountp) TALER_PQ_result_spec_amount ( \ + field,pg->currency,amountp) /** * Wrapper macro to add the currency from the plugin's state @@ -54,7 +55,9 @@ * @param field name of the database field to fetch amount from * @param amountp[out] pointer to amount to set */ -#define TALER_PQ_RESULT_SPEC_AMOUNT_NBO(field,amountp) TALER_PQ_result_spec_amount_nbo(field,pg->currency,amountp) +#define TALER_PQ_RESULT_SPEC_AMOUNT_NBO(field, \ + amountp) TALER_PQ_result_spec_amount_nbo ( \ + field,pg->currency,amountp) /** * Log a really unexpected PQ error with all the details we can get hold of. @@ -71,7 +74,7 @@ PQresultErrorMessage (result), \ PQresStatus (PQresultStatus (result)), \ PQerrorMessage (conn)); \ - } while (0) +} while (0) /** @@ -88,7 +91,7 @@ struct TALER_EXCHANGEDB_Session * Name of the current transaction, for debugging. */ const char *transaction_name; - + }; @@ -143,20 +146,25 @@ postgres_drop_tables (void *cls) GNUNET_PQ_make_execute ("DROP TABLE IF EXISTS prewire CASCADE;"), GNUNET_PQ_make_execute ("DROP TABLE IF EXISTS payback CASCADE;"), GNUNET_PQ_make_execute ("DROP TABLE IF EXISTS payback_refresh CASCADE;"), - GNUNET_PQ_make_execute ("DROP TABLE IF EXISTS aggregation_tracking CASCADE;"), + GNUNET_PQ_make_execute ( + "DROP TABLE IF EXISTS aggregation_tracking CASCADE;"), GNUNET_PQ_make_execute ("DROP TABLE IF EXISTS wire_out CASCADE;"), GNUNET_PQ_make_execute ("DROP TABLE IF EXISTS wire_fee CASCADE;"), GNUNET_PQ_make_execute ("DROP TABLE IF EXISTS deposits CASCADE;"), GNUNET_PQ_make_execute ("DROP TABLE IF EXISTS refunds CASCADE;"), - GNUNET_PQ_make_execute ("DROP TABLE IF EXISTS refresh_commitments CASCADE;"), - GNUNET_PQ_make_execute ("DROP TABLE IF EXISTS refresh_revealed_coins CASCADE;"), - GNUNET_PQ_make_execute ("DROP TABLE IF EXISTS refresh_transfer_keys CASCADE;"), + GNUNET_PQ_make_execute ( + "DROP TABLE IF EXISTS refresh_commitments CASCADE;"), + GNUNET_PQ_make_execute ( + "DROP TABLE IF EXISTS refresh_revealed_coins CASCADE;"), + GNUNET_PQ_make_execute ( + "DROP TABLE IF EXISTS refresh_transfer_keys CASCADE;"), GNUNET_PQ_make_execute ("DROP TABLE IF EXISTS known_coins CASCADE;"), GNUNET_PQ_make_execute ("DROP TABLE IF EXISTS reserves_close CASCADE;"), GNUNET_PQ_make_execute ("DROP TABLE IF EXISTS reserves_out CASCADE;"), GNUNET_PQ_make_execute ("DROP TABLE IF EXISTS reserves_in CASCADE;"), GNUNET_PQ_make_execute ("DROP TABLE IF EXISTS reserves CASCADE;"), - GNUNET_PQ_make_execute ("DROP TABLE IF EXISTS denomination_revocations CASCADE;"), + GNUNET_PQ_make_execute ( + "DROP TABLE IF EXISTS denomination_revocations CASCADE;"), GNUNET_PQ_make_execute ("DROP TABLE IF EXISTS denominations CASCADE;"), GNUNET_PQ_EXECUTE_STATEMENT_END }; @@ -211,15 +219,17 @@ postgres_create_tables (void *cls) ",fee_refund_frac INT4 NOT NULL" ")"), /* index for gc_denominations */ - GNUNET_PQ_make_try_execute ("CREATE INDEX denominations_expire_legal_index ON " - "denominations (expire_legal);"), + GNUNET_PQ_make_try_execute ( + "CREATE INDEX denominations_expire_legal_index ON " + "denominations (expire_legal);"), /* denomination_revocations table is for remembering which denomination keys have been revoked */ - GNUNET_PQ_make_execute ("CREATE TABLE IF NOT EXISTS denomination_revocations" - "(denom_revocations_serial_id BIGSERIAL UNIQUE" - ",denom_pub_hash BYTEA PRIMARY KEY REFERENCES denominations (denom_pub_hash) ON DELETE CASCADE" - ",master_sig BYTEA NOT NULL CHECK (LENGTH(master_sig)=64)" - ");"), + GNUNET_PQ_make_execute ( + "CREATE TABLE IF NOT EXISTS denomination_revocations" + "(denom_revocations_serial_id BIGSERIAL UNIQUE" + ",denom_pub_hash BYTEA PRIMARY KEY REFERENCES denominations (denom_pub_hash) ON DELETE CASCADE" + ",master_sig BYTEA NOT NULL CHECK (LENGTH(master_sig)=64)" + ");"), /* reserves table is for summarization of a reserve. It is updated when new funds are added and existing funds are withdrawn. The 'expiration_date' can be used to eventually get rid of reserves that have not been used @@ -245,17 +255,17 @@ postgres_create_tables (void *cls) /* reserves_in table collects the transactions which transfer funds into the reserve. The rows of this table correspond to each incoming transaction. */ - GNUNET_PQ_make_execute("CREATE TABLE IF NOT EXISTS reserves_in" - "(reserve_in_serial_id BIGSERIAL UNIQUE" - ",reserve_pub BYTEA NOT NULL REFERENCES reserves (reserve_pub) ON DELETE CASCADE" - ",wire_reference BYTEA NOT NULL" - ",credit_val INT8 NOT NULL" - ",credit_frac INT4 NOT NULL" - ",sender_account_details TEXT NOT NULL" - ",exchange_account_section TEXT NOT NULL" - ",execution_date INT8 NOT NULL" - ",PRIMARY KEY (reserve_pub, wire_reference)" - ");"), + GNUNET_PQ_make_execute ("CREATE TABLE IF NOT EXISTS reserves_in" + "(reserve_in_serial_id BIGSERIAL UNIQUE" + ",reserve_pub BYTEA NOT NULL REFERENCES reserves (reserve_pub) ON DELETE CASCADE" + ",wire_reference BYTEA NOT NULL" + ",credit_val INT8 NOT NULL" + ",credit_frac INT4 NOT NULL" + ",sender_account_details TEXT NOT NULL" + ",exchange_account_section TEXT NOT NULL" + ",execution_date INT8 NOT NULL" + ",PRIMARY KEY (reserve_pub, wire_reference)" + ");"), /* Create indices on reserves_in */ GNUNET_PQ_make_try_execute ("CREATE INDEX reserves_in_execution_index" " ON reserves_in (exchange_account_section,execution_date);"), @@ -263,24 +273,25 @@ postgres_create_tables (void *cls) reserve_pub as the first dimension! */ GNUNET_PQ_make_try_execute ("CREATE INDEX reserves_in_reserve_pub" " ON reserves_in (reserve_pub);"), - GNUNET_PQ_make_try_execute ("CREATE INDEX reserves_in_exchange_account_serial" - " ON reserves_in (exchange_account_section,reserve_in_serial_id DESC);"), + GNUNET_PQ_make_try_execute ( + "CREATE INDEX reserves_in_exchange_account_serial" + " ON reserves_in (exchange_account_section,reserve_in_serial_id DESC);"), /* This table contains the data for wire transfers the exchange has executed to close a reserve. */ - GNUNET_PQ_make_execute("CREATE TABLE IF NOT EXISTS reserves_close " - "(close_uuid BIGSERIAL PRIMARY KEY" - ",reserve_pub BYTEA NOT NULL REFERENCES reserves (reserve_pub) ON DELETE CASCADE" - ",execution_date INT8 NOT NULL" - ",wtid BYTEA NOT NULL CHECK (LENGTH(wtid)=32)" - ",receiver_account TEXT NOT NULL" - ",amount_val INT8 NOT NULL" - ",amount_frac INT4 NOT NULL" - ",closing_fee_val INT8 NOT NULL" - ",closing_fee_frac INT4 NOT NULL" - ");"), - GNUNET_PQ_make_try_execute("CREATE INDEX reserves_close_by_reserve " - "ON reserves_close(reserve_pub)"), + GNUNET_PQ_make_execute ("CREATE TABLE IF NOT EXISTS reserves_close " + "(close_uuid BIGSERIAL PRIMARY KEY" + ",reserve_pub BYTEA NOT NULL REFERENCES reserves (reserve_pub) ON DELETE CASCADE" + ",execution_date INT8 NOT NULL" + ",wtid BYTEA NOT NULL CHECK (LENGTH(wtid)=32)" + ",receiver_account TEXT NOT NULL" + ",amount_val INT8 NOT NULL" + ",amount_frac INT4 NOT NULL" + ",closing_fee_val INT8 NOT NULL" + ",closing_fee_frac INT4 NOT NULL" + ");"), + GNUNET_PQ_make_try_execute ("CREATE INDEX reserves_close_by_reserve " + "ON reserves_close(reserve_pub)"), /* Table with the withdraw operations that have been performed on a reserve. The 'h_blind_ev' is the hash of the blinded coin. It serves as a primary key, as (broken) clients that use a non-random coin and blinding factor @@ -302,30 +313,32 @@ postgres_create_tables (void *cls) " reserves_out (reserve_pub)"), GNUNET_PQ_make_try_execute ("CREATE INDEX reserves_out_execution_date ON " "reserves_out (execution_date)"), - GNUNET_PQ_make_try_execute ("CREATE INDEX reserves_out_for_get_withdraw_info ON " - "reserves_out (denom_pub_hash,h_blind_ev)"), + GNUNET_PQ_make_try_execute ( + "CREATE INDEX reserves_out_for_get_withdraw_info ON " + "reserves_out (denom_pub_hash,h_blind_ev)"), /* Table with coins that have been (partially) spent, used to track coin information only once. */ - GNUNET_PQ_make_execute("CREATE TABLE IF NOT EXISTS known_coins " - "(coin_pub BYTEA NOT NULL PRIMARY KEY CHECK (LENGTH(coin_pub)=32)" - ",denom_pub_hash BYTEA NOT NULL REFERENCES denominations (denom_pub_hash) ON DELETE CASCADE" - ",denom_sig BYTEA NOT NULL" - ");"), + GNUNET_PQ_make_execute ("CREATE TABLE IF NOT EXISTS known_coins " + "(coin_pub BYTEA NOT NULL PRIMARY KEY CHECK (LENGTH(coin_pub)=32)" + ",denom_pub_hash BYTEA NOT NULL REFERENCES denominations (denom_pub_hash) ON DELETE CASCADE" + ",denom_sig BYTEA NOT NULL" + ");"), GNUNET_PQ_make_try_execute ("CREATE INDEX known_coins_by_denomination ON " "known_coins (denom_pub_hash)"), /* Table with the commitments made when melting a coin. */ - GNUNET_PQ_make_execute("CREATE TABLE IF NOT EXISTS refresh_commitments " - "(melt_serial_id BIGSERIAL UNIQUE" - ",rc BYTEA PRIMARY KEY CHECK (LENGTH(rc)=64)" - ",old_coin_pub BYTEA NOT NULL REFERENCES known_coins (coin_pub) ON DELETE CASCADE" - ",old_coin_sig BYTEA NOT NULL CHECK(LENGTH(old_coin_sig)=64)" - ",amount_with_fee_val INT8 NOT NULL" - ",amount_with_fee_frac INT4 NOT NULL" - ",noreveal_index INT4 NOT NULL" - ");"), - GNUNET_PQ_make_try_execute ("CREATE INDEX refresh_commitments_old_coin_pub_index ON " - "refresh_commitments (old_coin_pub);"), + GNUNET_PQ_make_execute ("CREATE TABLE IF NOT EXISTS refresh_commitments " + "(melt_serial_id BIGSERIAL UNIQUE" + ",rc BYTEA PRIMARY KEY CHECK (LENGTH(rc)=64)" + ",old_coin_pub BYTEA NOT NULL REFERENCES known_coins (coin_pub) ON DELETE CASCADE" + ",old_coin_sig BYTEA NOT NULL CHECK(LENGTH(old_coin_sig)=64)" + ",amount_with_fee_val INT8 NOT NULL" + ",amount_with_fee_frac INT4 NOT NULL" + ",noreveal_index INT4 NOT NULL" + ");"), + GNUNET_PQ_make_try_execute ( + "CREATE INDEX refresh_commitments_old_coin_pub_index ON " + "refresh_commitments (old_coin_pub);"), /* Table with the revelations about the new coins that are to be created during a melting session. Includes the session, the cut-and-choose @@ -333,172 +346,176 @@ postgres_create_tables (void *cls) coin to be signed, as well as the encrypted information about the private key and the blinding factor for the coin (for verification in case this newcoin_index is chosen to be revealed) */ - GNUNET_PQ_make_execute("CREATE TABLE IF NOT EXISTS refresh_revealed_coins " - "(rc BYTEA NOT NULL REFERENCES refresh_commitments (rc) ON DELETE CASCADE" - ",newcoin_index INT4 NOT NULL" - ",link_sig BYTEA NOT NULL CHECK(LENGTH(link_sig)=64)" - ",denom_pub_hash BYTEA NOT NULL REFERENCES denominations (denom_pub_hash) ON DELETE CASCADE" - ",coin_ev BYTEA UNIQUE NOT NULL" - ",h_coin_ev BYTEA NOT NULL CHECK(LENGTH(h_coin_ev)=64)" - ",ev_sig BYTEA NOT NULL" - ",PRIMARY KEY (rc, newcoin_index)" - ",UNIQUE (h_coin_ev)" - ");"), - GNUNET_PQ_make_try_execute ("CREATE INDEX refresh_revealed_coins_coin_pub_index ON " - "refresh_revealed_coins (denom_pub_hash);"), + GNUNET_PQ_make_execute ("CREATE TABLE IF NOT EXISTS refresh_revealed_coins " + "(rc BYTEA NOT NULL REFERENCES refresh_commitments (rc) ON DELETE CASCADE" + ",newcoin_index INT4 NOT NULL" + ",link_sig BYTEA NOT NULL CHECK(LENGTH(link_sig)=64)" + ",denom_pub_hash BYTEA NOT NULL REFERENCES denominations (denom_pub_hash) ON DELETE CASCADE" + ",coin_ev BYTEA UNIQUE NOT NULL" + ",h_coin_ev BYTEA NOT NULL CHECK(LENGTH(h_coin_ev)=64)" + ",ev_sig BYTEA NOT NULL" + ",PRIMARY KEY (rc, newcoin_index)" + ",UNIQUE (h_coin_ev)" + ");"), + GNUNET_PQ_make_try_execute ( + "CREATE INDEX refresh_revealed_coins_coin_pub_index ON " + "refresh_revealed_coins (denom_pub_hash);"), /* Table with the transfer keys of a refresh operation; includes the rc for which this is the link information, the transfer public key (for gamma) and the revealed transfer private keys (array of TALER_CNC_KAPPA - 1 entries, with gamma being skipped) */ - GNUNET_PQ_make_execute("CREATE TABLE IF NOT EXISTS refresh_transfer_keys " - "(rc BYTEA NOT NULL PRIMARY KEY REFERENCES refresh_commitments (rc) ON DELETE CASCADE" - ",transfer_pub BYTEA NOT NULL CHECK(LENGTH(transfer_pub)=32)" - ",transfer_privs BYTEA NOT NULL" - ");"), + GNUNET_PQ_make_execute ("CREATE TABLE IF NOT EXISTS refresh_transfer_keys " + "(rc BYTEA NOT NULL PRIMARY KEY REFERENCES refresh_commitments (rc) ON DELETE CASCADE" + ",transfer_pub BYTEA NOT NULL CHECK(LENGTH(transfer_pub)=32)" + ",transfer_privs BYTEA NOT NULL" + ");"), /* for "get_link" (not sure if this helps, as there should be very few transfer_pubs per rc, but at least in theory this helps the ORDER BY clause. */ - GNUNET_PQ_make_try_execute ("CREATE INDEX refresh_transfer_keys_coin_tpub ON " - "refresh_transfer_keys (rc,transfer_pub);"), + GNUNET_PQ_make_try_execute ( + "CREATE INDEX refresh_transfer_keys_coin_tpub ON " + "refresh_transfer_keys (rc,transfer_pub);"), /* This table contains the wire transfers the exchange is supposed to execute to transmit funds to the merchants (and manage refunds). */ - GNUNET_PQ_make_execute("CREATE TABLE IF NOT EXISTS deposits " - "(deposit_serial_id BIGSERIAL PRIMARY KEY" - ",coin_pub BYTEA NOT NULL REFERENCES known_coins (coin_pub) ON DELETE CASCADE" - ",amount_with_fee_val INT8 NOT NULL" - ",amount_with_fee_frac INT4 NOT NULL" - ",timestamp INT8 NOT NULL" - ",refund_deadline INT8 NOT NULL" - ",wire_deadline INT8 NOT NULL" - ",merchant_pub BYTEA NOT NULL CHECK (LENGTH(merchant_pub)=32)" - ",h_contract_terms BYTEA NOT NULL CHECK (LENGTH(h_contract_terms)=64)" - ",h_wire BYTEA NOT NULL CHECK (LENGTH(h_wire)=64)" - ",coin_sig BYTEA NOT NULL CHECK (LENGTH(coin_sig)=64)" - ",wire TEXT NOT NULL" - ",tiny BOOLEAN NOT NULL DEFAULT FALSE" - ",done BOOLEAN NOT NULL DEFAULT FALSE" - ",UNIQUE (coin_pub, merchant_pub, h_contract_terms)" - ");"), + GNUNET_PQ_make_execute ("CREATE TABLE IF NOT EXISTS deposits " + "(deposit_serial_id BIGSERIAL PRIMARY KEY" + ",coin_pub BYTEA NOT NULL REFERENCES known_coins (coin_pub) ON DELETE CASCADE" + ",amount_with_fee_val INT8 NOT NULL" + ",amount_with_fee_frac INT4 NOT NULL" + ",timestamp INT8 NOT NULL" + ",refund_deadline INT8 NOT NULL" + ",wire_deadline INT8 NOT NULL" + ",merchant_pub BYTEA NOT NULL CHECK (LENGTH(merchant_pub)=32)" + ",h_contract_terms BYTEA NOT NULL CHECK (LENGTH(h_contract_terms)=64)" + ",h_wire BYTEA NOT NULL CHECK (LENGTH(h_wire)=64)" + ",coin_sig BYTEA NOT NULL CHECK (LENGTH(coin_sig)=64)" + ",wire TEXT NOT NULL" + ",tiny BOOLEAN NOT NULL DEFAULT FALSE" + ",done BOOLEAN NOT NULL DEFAULT FALSE" + ",UNIQUE (coin_pub, merchant_pub, h_contract_terms)" + ");"), /* Index for get_deposit_for_wtid and get_deposit_statement */ - GNUNET_PQ_make_try_execute("CREATE INDEX deposits_coin_pub_merchant_contract_index " - "ON deposits(coin_pub, merchant_pub, h_contract_terms)"), + GNUNET_PQ_make_try_execute ( + "CREATE INDEX deposits_coin_pub_merchant_contract_index " + "ON deposits(coin_pub, merchant_pub, h_contract_terms)"), /* Index for deposits_get_ready */ - GNUNET_PQ_make_try_execute("CREATE INDEX deposits_get_ready_index " - "ON deposits(tiny,done,wire_deadline,refund_deadline)"), + GNUNET_PQ_make_try_execute ("CREATE INDEX deposits_get_ready_index " + "ON deposits(tiny,done,wire_deadline,refund_deadline)"), /* Index for deposits_iterate_matching */ - GNUNET_PQ_make_try_execute("CREATE INDEX deposits_iterate_matching " - "ON deposits(merchant_pub,h_wire,done,wire_deadline)"), + GNUNET_PQ_make_try_execute ("CREATE INDEX deposits_iterate_matching " + "ON deposits(merchant_pub,h_wire,done,wire_deadline)"), /* Table with information about coins that have been refunded. (Technically one of the deposit operations that a coin was involved with is refunded.)*/ - GNUNET_PQ_make_execute("CREATE TABLE IF NOT EXISTS refunds " - "(refund_serial_id BIGSERIAL UNIQUE" - ",coin_pub BYTEA NOT NULL REFERENCES known_coins (coin_pub) ON DELETE CASCADE" - ",merchant_pub BYTEA NOT NULL CHECK(LENGTH(merchant_pub)=32)" - ",merchant_sig BYTEA NOT NULL CHECK(LENGTH(merchant_sig)=64)" - ",h_contract_terms BYTEA NOT NULL CHECK(LENGTH(h_contract_terms)=64)" - ",rtransaction_id INT8 NOT NULL" - ",amount_with_fee_val INT8 NOT NULL" - ",amount_with_fee_frac INT4 NOT NULL" - ",PRIMARY KEY (coin_pub, merchant_pub, h_contract_terms, rtransaction_id)" /* this combo must be unique, and we usually select by coin_pub */ - ");"), - GNUNET_PQ_make_try_execute("CREATE INDEX refunds_coin_pub_index " - "ON refunds(coin_pub)"), + GNUNET_PQ_make_execute ("CREATE TABLE IF NOT EXISTS refunds " + "(refund_serial_id BIGSERIAL UNIQUE" + ",coin_pub BYTEA NOT NULL REFERENCES known_coins (coin_pub) ON DELETE CASCADE" + ",merchant_pub BYTEA NOT NULL CHECK(LENGTH(merchant_pub)=32)" + ",merchant_sig BYTEA NOT NULL CHECK(LENGTH(merchant_sig)=64)" + ",h_contract_terms BYTEA NOT NULL CHECK(LENGTH(h_contract_terms)=64)" + ",rtransaction_id INT8 NOT NULL" + ",amount_with_fee_val INT8 NOT NULL" + ",amount_with_fee_frac INT4 NOT NULL" + ",PRIMARY KEY (coin_pub, merchant_pub, h_contract_terms, rtransaction_id)" /* this combo must be unique, and we usually select by coin_pub */ + ");"), + GNUNET_PQ_make_try_execute ("CREATE INDEX refunds_coin_pub_index " + "ON refunds(coin_pub)"), /* This table contains the data for wire transfers the exchange has executed. */ - GNUNET_PQ_make_execute("CREATE TABLE IF NOT EXISTS wire_out " - "(wireout_uuid BIGSERIAL PRIMARY KEY" - ",execution_date INT8 NOT NULL" - ",wtid_raw BYTEA UNIQUE NOT NULL CHECK (LENGTH(wtid_raw)=" TALER_WIRE_TRANSFER_IDENTIFIER_LEN_STR ")" - ",wire_target TEXT NOT NULL" - ",exchange_account_section TEXT NOT NULL" - ",amount_val INT8 NOT NULL" - ",amount_frac INT4 NOT NULL" - ");"), + GNUNET_PQ_make_execute ("CREATE TABLE IF NOT EXISTS wire_out " + "(wireout_uuid BIGSERIAL PRIMARY KEY" + ",execution_date INT8 NOT NULL" + ",wtid_raw BYTEA UNIQUE NOT NULL CHECK (LENGTH(wtid_raw)=" + TALER_WIRE_TRANSFER_IDENTIFIER_LEN_STR ")" + ",wire_target TEXT NOT NULL" + ",exchange_account_section TEXT NOT NULL" + ",amount_val INT8 NOT NULL" + ",amount_frac INT4 NOT NULL" + ");"), /* Table for the tracking API, mapping from wire transfer identifiers to transactions and back */ - GNUNET_PQ_make_execute("CREATE TABLE IF NOT EXISTS aggregation_tracking " - "(aggregation_serial_id BIGSERIAL UNIQUE" - ",deposit_serial_id INT8 PRIMARY KEY REFERENCES deposits (deposit_serial_id) ON DELETE CASCADE" - ",wtid_raw BYTEA CONSTRAINT wire_out_ref REFERENCES wire_out(wtid_raw) ON DELETE CASCADE DEFERRABLE" - ");"), + GNUNET_PQ_make_execute ("CREATE TABLE IF NOT EXISTS aggregation_tracking " + "(aggregation_serial_id BIGSERIAL UNIQUE" + ",deposit_serial_id INT8 PRIMARY KEY REFERENCES deposits (deposit_serial_id) ON DELETE CASCADE" + ",wtid_raw BYTEA CONSTRAINT wire_out_ref REFERENCES wire_out(wtid_raw) ON DELETE CASCADE DEFERRABLE" + ");"), /* Index for lookup_transactions statement on wtid */ - GNUNET_PQ_make_try_execute("CREATE INDEX aggregation_tracking_wtid_index " - "ON aggregation_tracking(wtid_raw)"), + GNUNET_PQ_make_try_execute ("CREATE INDEX aggregation_tracking_wtid_index " + "ON aggregation_tracking(wtid_raw)"), /* Table for the wire fees. */ - GNUNET_PQ_make_execute("CREATE TABLE IF NOT EXISTS wire_fee " - "(wire_method VARCHAR NOT NULL" - ",start_date INT8 NOT NULL" - ",end_date INT8 NOT NULL" - ",wire_fee_val INT8 NOT NULL" - ",wire_fee_frac INT4 NOT NULL" - ",closing_fee_val INT8 NOT NULL" - ",closing_fee_frac INT4 NOT NULL" - ",master_sig BYTEA NOT NULL CHECK (LENGTH(master_sig)=64)" - ",PRIMARY KEY (wire_method, start_date)" /* this combo must be unique */ - ");"), + GNUNET_PQ_make_execute ("CREATE TABLE IF NOT EXISTS wire_fee " + "(wire_method VARCHAR NOT NULL" + ",start_date INT8 NOT NULL" + ",end_date INT8 NOT NULL" + ",wire_fee_val INT8 NOT NULL" + ",wire_fee_frac INT4 NOT NULL" + ",closing_fee_val INT8 NOT NULL" + ",closing_fee_frac INT4 NOT NULL" + ",master_sig BYTEA NOT NULL CHECK (LENGTH(master_sig)=64)" + ",PRIMARY KEY (wire_method, start_date)" /* this combo must be unique */ + ");"), /* Index for lookup_transactions statement on wtid */ - GNUNET_PQ_make_try_execute("CREATE INDEX aggregation_tracking_wtid_index " - "ON aggregation_tracking(wtid_raw);"), + GNUNET_PQ_make_try_execute ("CREATE INDEX aggregation_tracking_wtid_index " + "ON aggregation_tracking(wtid_raw);"), /* Index for gc_wire_fee */ - GNUNET_PQ_make_try_execute("CREATE INDEX wire_fee_gc_index " - "ON wire_fee(end_date);"), + GNUNET_PQ_make_try_execute ("CREATE INDEX wire_fee_gc_index " + "ON wire_fee(end_date);"), /* Table for /payback information */ - GNUNET_PQ_make_execute("CREATE TABLE IF NOT EXISTS payback " - "(payback_uuid BIGSERIAL UNIQUE" - ",coin_pub BYTEA NOT NULL REFERENCES known_coins (coin_pub)" /* do NOT CASCADE on delete, we may keep the coin alive! */ - ",coin_sig BYTEA NOT NULL CHECK(LENGTH(coin_sig)=64)" - ",coin_blind BYTEA NOT NULL CHECK(LENGTH(coin_blind)=32)" - ",amount_val INT8 NOT NULL" - ",amount_frac INT4 NOT NULL" - ",timestamp INT8 NOT NULL" - ",h_blind_ev BYTEA NOT NULL REFERENCES reserves_out (h_blind_ev) ON DELETE CASCADE" - ");"), - GNUNET_PQ_make_try_execute("CREATE INDEX payback_by_coin_index " - "ON payback(coin_pub);"), - GNUNET_PQ_make_try_execute("CREATE INDEX payback_by_h_blind_ev " - "ON payback(h_blind_ev);"), - GNUNET_PQ_make_try_execute("CREATE INDEX payback_by_reserve_index " - "ON payback(reserve_pub);"), - GNUNET_PQ_make_try_execute("CREATE INDEX payback_for_by_reserve " - "ON payback(coin_pub,denom_pub_hash,h_blind_ev);"), + GNUNET_PQ_make_execute ("CREATE TABLE IF NOT EXISTS payback " + "(payback_uuid BIGSERIAL UNIQUE" + ",coin_pub BYTEA NOT NULL REFERENCES known_coins (coin_pub)" /* do NOT CASCADE on delete, we may keep the coin alive! */ + ",coin_sig BYTEA NOT NULL CHECK(LENGTH(coin_sig)=64)" + ",coin_blind BYTEA NOT NULL CHECK(LENGTH(coin_blind)=32)" + ",amount_val INT8 NOT NULL" + ",amount_frac INT4 NOT NULL" + ",timestamp INT8 NOT NULL" + ",h_blind_ev BYTEA NOT NULL REFERENCES reserves_out (h_blind_ev) ON DELETE CASCADE" + ");"), + GNUNET_PQ_make_try_execute ("CREATE INDEX payback_by_coin_index " + "ON payback(coin_pub);"), + GNUNET_PQ_make_try_execute ("CREATE INDEX payback_by_h_blind_ev " + "ON payback(h_blind_ev);"), + GNUNET_PQ_make_try_execute ("CREATE INDEX payback_by_reserve_index " + "ON payback(reserve_pub);"), + GNUNET_PQ_make_try_execute ("CREATE INDEX payback_for_by_reserve " + "ON payback(coin_pub,denom_pub_hash,h_blind_ev);"), /* Table for /payback-refresh information */ - GNUNET_PQ_make_execute("CREATE TABLE IF NOT EXISTS payback_refresh " - "(payback_refresh_uuid BIGSERIAL UNIQUE" - ",coin_pub BYTEA NOT NULL REFERENCES known_coins (coin_pub)" /* do NOT CASCADE on delete, we may keep the coin alive! */ - ",coin_sig BYTEA NOT NULL CHECK(LENGTH(coin_sig)=64)" - ",coin_blind BYTEA NOT NULL CHECK(LENGTH(coin_blind)=32)" - ",amount_val INT8 NOT NULL" - ",amount_frac INT4 NOT NULL" - ",timestamp INT8 NOT NULL" - ",h_blind_ev BYTEA NOT NULL REFERENCES refresh_revealed_coins (h_coin_ev) ON DELETE CASCADE" - ");"), - GNUNET_PQ_make_try_execute("CREATE INDEX payback_refresh_by_coin_index " - "ON payback_refresh(coin_pub);"), - GNUNET_PQ_make_try_execute("CREATE INDEX payback_refresh_by_h_blind_ev " - "ON payback_refresh(h_blind_ev);"), - GNUNET_PQ_make_try_execute("CREATE INDEX payback_refresh_by_reserve_index " - "ON payback_refresh(reserve_pub);"), - GNUNET_PQ_make_try_execute("CREATE INDEX payback_refresh_for_by_reserve " - "ON payback_refresh(coin_pub,denom_pub_hash,h_blind_ev);"), + GNUNET_PQ_make_execute ("CREATE TABLE IF NOT EXISTS payback_refresh " + "(payback_refresh_uuid BIGSERIAL UNIQUE" + ",coin_pub BYTEA NOT NULL REFERENCES known_coins (coin_pub)" /* do NOT CASCADE on delete, we may keep the coin alive! */ + ",coin_sig BYTEA NOT NULL CHECK(LENGTH(coin_sig)=64)" + ",coin_blind BYTEA NOT NULL CHECK(LENGTH(coin_blind)=32)" + ",amount_val INT8 NOT NULL" + ",amount_frac INT4 NOT NULL" + ",timestamp INT8 NOT NULL" + ",h_blind_ev BYTEA NOT NULL REFERENCES refresh_revealed_coins (h_coin_ev) ON DELETE CASCADE" + ");"), + GNUNET_PQ_make_try_execute ("CREATE INDEX payback_refresh_by_coin_index " + "ON payback_refresh(coin_pub);"), + GNUNET_PQ_make_try_execute ("CREATE INDEX payback_refresh_by_h_blind_ev " + "ON payback_refresh(h_blind_ev);"), + GNUNET_PQ_make_try_execute ("CREATE INDEX payback_refresh_by_reserve_index " + "ON payback_refresh(reserve_pub);"), + GNUNET_PQ_make_try_execute ("CREATE INDEX payback_refresh_for_by_reserve " + "ON payback_refresh(coin_pub,denom_pub_hash,h_blind_ev);"), /* This table contains the pre-commit data for wire transfers the exchange is about to execute. */ - GNUNET_PQ_make_execute("CREATE TABLE IF NOT EXISTS prewire " - "(prewire_uuid BIGSERIAL PRIMARY KEY" - ",type TEXT NOT NULL" - ",finished BOOLEAN NOT NULL DEFAULT false" - ",buf BYTEA NOT NULL" - ");"), + GNUNET_PQ_make_execute ("CREATE TABLE IF NOT EXISTS prewire " + "(prewire_uuid BIGSERIAL PRIMARY KEY" + ",type TEXT NOT NULL" + ",finished BOOLEAN NOT NULL DEFAULT false" + ",buf BYTEA NOT NULL" + ");"), /* Index for wire_prepare_data_get and gc_prewire statement */ - GNUNET_PQ_make_try_execute("CREATE INDEX prepare_iteration_index " - "ON prewire(finished);"), + GNUNET_PQ_make_try_execute ("CREATE INDEX prepare_iteration_index " + "ON prewire(finished);"), GNUNET_PQ_EXECUTE_STATEMENT_END }; PGconn *conn; @@ -700,19 +717,20 @@ postgres_prepare (PGconn *db_conn) 1), /* Used in postgres_select_reserves_in_above_serial_id() to obtain inbound transactions for reserves with serial id '\geq' the given parameter */ - GNUNET_PQ_make_prepare ("audit_reserves_in_get_transactions_incr_by_account", - "SELECT" - " reserve_pub" - ",wire_reference" - ",credit_val" - ",credit_frac" - ",execution_date" - ",sender_account_details" - ",reserve_in_serial_id" - " FROM reserves_in" - " WHERE reserve_in_serial_id>=$1 AND exchange_account_section=$2" - " ORDER BY reserve_in_serial_id;", - 2), + GNUNET_PQ_make_prepare ( + "audit_reserves_in_get_transactions_incr_by_account", + "SELECT" + " reserve_pub" + ",wire_reference" + ",credit_val" + ",credit_frac" + ",execution_date" + ",sender_account_details" + ",reserve_in_serial_id" + " FROM reserves_in" + " WHERE reserve_in_serial_id>=$1 AND exchange_account_section=$2" + " ORDER BY reserve_in_serial_id;", + 2), /* Used in #postgres_get_reserve_history() to obtain inbound transactions for a reserve */ GNUNET_PQ_make_prepare ("reserves_in_get_transactions", @@ -1148,7 +1166,8 @@ postgres_prepare (PGconn *db_conn) " h_wire=$2 AND" " done=FALSE" " ORDER BY wire_deadline ASC" - " LIMIT " TALER_EXCHANGEDB_MATCHING_DEPOSITS_LIMIT_STR ";", + " LIMIT " + TALER_EXCHANGEDB_MATCHING_DEPOSITS_LIMIT_STR ";", 2), /* Used in #postgres_mark_deposit_tiny() */ GNUNET_PQ_make_prepare ("mark_deposit_tiny", @@ -1359,7 +1378,7 @@ postgres_prepare (PGconn *db_conn) " FROM aggregation_tracking" " WHERE (aggregation_tracking.deposit_serial_id = deposits.deposit_serial_id)))" " ORDER BY wire_deadline ASC", - 2), + 2), /* Used in #postgres_gc() */ GNUNET_PQ_make_prepare ("gc_prewire", "DELETE" @@ -1888,8 +1907,11 @@ postgres_preflight (void *cls, static enum GNUNET_DB_QueryStatus postgres_insert_denomination_info (void *cls, struct TALER_EXCHANGEDB_Session *session, - const struct TALER_DenominationPublicKey *denom_pub, - const struct TALER_EXCHANGEDB_DenominationKeyInformationP *issue) + const struct + TALER_DenominationPublicKey *denom_pub, + const struct + TALER_EXCHANGEDB_DenominationKeyInformationP + *issue) { struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (&issue->properties.denom_hash), @@ -1920,7 +1942,7 @@ postgres_insert_denomination_info (void *cls, &issue->properties.fee_refresh)); GNUNET_assert (GNUNET_YES == TALER_amount_cmp_currency_nbo (&issue->properties.value, - &issue->properties.fee_refund)); + &issue->properties.fee_refund)); return GNUNET_PQ_eval_prepared_non_select (session->conn, "denomination_insert", @@ -1941,7 +1963,9 @@ static enum GNUNET_DB_QueryStatus postgres_get_denomination_info (void *cls, struct TALER_EXCHANGEDB_Session *session, const struct GNUNET_HashCode *denom_pub_hash, - struct TALER_EXCHANGEDB_DenominationKeyInformationP *issue) + struct + TALER_EXCHANGEDB_DenominationKeyInformationP * + issue) { struct PostgresClosure *pg = cls; enum GNUNET_DB_QueryStatus qs; @@ -1981,8 +2005,10 @@ postgres_get_denomination_info (void *cls, rs); if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != qs) return qs; - issue->properties.purpose.size = htonl (sizeof (struct TALER_DenominationKeyValidityPS)); - issue->properties.purpose.purpose = htonl (TALER_SIGNATURE_MASTER_DENOMINATION_KEY_VALIDITY); + issue->properties.purpose.size = htonl (sizeof (struct + TALER_DenominationKeyValidityPS)); + issue->properties.purpose.purpose = htonl ( + TALER_SIGNATURE_MASTER_DENOMINATION_KEY_VALIDITY); issue->properties.denom_hash = *denom_pub_hash; return qs; } @@ -2025,37 +2051,37 @@ domination_cb_helper (void *cls, { struct DenomIteratorContext *dic = cls; struct PostgresClosure *pg = dic->pg; - - for (unsigned int i=0;ipub), + GNUNET_PQ_query_param_auto_from_type (&reserve->pub), GNUNET_PQ_query_param_end }; struct GNUNET_PQ_ResultSpec rs[] = { - TALER_PQ_RESULT_SPEC_AMOUNT("current_balance", &reserve->balance), - TALER_PQ_result_spec_absolute_time("expiration_date", &reserve->expiry), - TALER_PQ_result_spec_absolute_time("gc_date", &reserve->gc), + TALER_PQ_RESULT_SPEC_AMOUNT ("current_balance", &reserve->balance), + TALER_PQ_result_spec_absolute_time ("expiration_date", &reserve->expiry), + TALER_PQ_result_spec_absolute_time ("gc_date", &reserve->gc), GNUNET_PQ_result_spec_end }; @@ -2237,8 +2263,9 @@ postgres_reserves_in_insert (void *cls, GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Creating reserve %s with expiration in %s\n", TALER_B2S (reserve_pub), - GNUNET_STRINGS_relative_time_to_string (pg->idle_reserve_expiration_time, - GNUNET_NO)); + GNUNET_STRINGS_relative_time_to_string ( + pg->idle_reserve_expiration_time, + GNUNET_NO)); expiry = GNUNET_TIME_absolute_add (execution_time, pg->idle_reserve_expiration_time); (void) GNUNET_TIME_round_abs (&expiry); @@ -2347,7 +2374,8 @@ postgres_reserves_in_insert (void *cls, */ static enum GNUNET_DB_QueryStatus postgres_get_latest_reserve_in_reference (void *cls, - struct TALER_EXCHANGEDB_Session *session, + struct TALER_EXCHANGEDB_Session * + session, const char *exchange_account_name, void **wire_reference, size_t *wire_reference_size) @@ -2386,7 +2414,8 @@ static enum GNUNET_DB_QueryStatus postgres_get_withdraw_info (void *cls, struct TALER_EXCHANGEDB_Session *session, const struct GNUNET_HashCode *h_blind, - struct TALER_EXCHANGEDB_CollectableBlindcoin *collectable) + struct TALER_EXCHANGEDB_CollectableBlindcoin * + collectable) { struct PostgresClosure *pg = cls; struct GNUNET_PQ_QueryParam no_params[] = { @@ -2438,7 +2467,9 @@ postgres_get_withdraw_info (void *cls, static enum GNUNET_DB_QueryStatus postgres_insert_withdraw_info (void *cls, struct TALER_EXCHANGEDB_Session *session, - const struct TALER_EXCHANGEDB_CollectableBlindcoin *collectable) + const struct + TALER_EXCHANGEDB_CollectableBlindcoin * + collectable) { struct PostgresClosure *pg = cls; struct TALER_EXCHANGEDB_Reserve reserve; @@ -2649,7 +2680,7 @@ add_withdraw_coin (void *cls, cbc = GNUNET_new (struct TALER_EXCHANGEDB_CollectableBlindcoin); { struct GNUNET_PQ_ResultSpec rs[] = { - GNUNET_PQ_result_spec_auto_from_type ("h_blind_ev", + GNUNET_PQ_result_spec_auto_from_type ("h_blind_ev", &cbc->h_coin_envelope), GNUNET_PQ_result_spec_auto_from_type ("denom_pub_hash", &cbc->denom_pub_hash), @@ -2719,7 +2750,8 @@ add_payback (void *cls, GNUNET_PQ_result_spec_auto_from_type ("denom_pub_hash", &payback->coin.denom_pub_hash), GNUNET_PQ_result_spec_rsa_signature ("denom_sig", - &payback->coin.denom_sig.rsa_signature), + &payback->coin.denom_sig. + rsa_signature), GNUNET_PQ_result_spec_end }; @@ -2757,7 +2789,7 @@ add_exchange_to_bank (void *cls, { struct ReserveHistoryContext *rhc = cls; struct PostgresClosure *pg = rhc->pg; - + while (0 < num_results) { struct TALER_EXCHANGEDB_ClosingTransfer *closing; @@ -2766,28 +2798,28 @@ add_exchange_to_bank (void *cls, closing = GNUNET_new (struct TALER_EXCHANGEDB_ClosingTransfer); { struct GNUNET_PQ_ResultSpec rs[] = { - TALER_PQ_RESULT_SPEC_AMOUNT ("amount", - &closing->amount), - TALER_PQ_RESULT_SPEC_AMOUNT ("closing_fee", - &closing->closing_fee), - TALER_PQ_result_spec_absolute_time ("execution_date", - &closing->execution_date), - GNUNET_PQ_result_spec_string ("receiver_account", + TALER_PQ_RESULT_SPEC_AMOUNT ("amount", + &closing->amount), + TALER_PQ_RESULT_SPEC_AMOUNT ("closing_fee", + &closing->closing_fee), + TALER_PQ_result_spec_absolute_time ("execution_date", + &closing->execution_date), + GNUNET_PQ_result_spec_string ("receiver_account", &closing->receiver_account_details), - GNUNET_PQ_result_spec_auto_from_type ("wtid", - &closing->wtid), - GNUNET_PQ_result_spec_end + GNUNET_PQ_result_spec_auto_from_type ("wtid", + &closing->wtid), + GNUNET_PQ_result_spec_end }; if (GNUNET_OK != - GNUNET_PQ_extract_result (result, - rs, - --num_results)) + GNUNET_PQ_extract_result (result, + rs, + --num_results)) { - GNUNET_break (0); - GNUNET_free (closing); - rhc->status = GNUNET_SYSERR; - return; + GNUNET_break (0); + GNUNET_free (closing); + rhc->status = GNUNET_SYSERR; + return; } } closing->reserve_pub = *rhc->reserve_pub; @@ -2816,7 +2848,8 @@ postgres_get_reserve_history (void *cls, { struct PostgresClosure *pg = cls; struct ReserveHistoryContext rhc; - struct { + struct + { /** * Name of the prepared statement to run. */ @@ -2854,15 +2887,15 @@ postgres_get_reserve_history (void *cls, rhc.pg = pg; rhc.status = GNUNET_OK; qs = GNUNET_DB_STATUS_SUCCESS_NO_RESULTS; /* make static analysis happy */ - for (unsigned int i=0;NULL != work[i].cb;i++) + for (unsigned int i = 0; NULL != work[i].cb; i++) { qs = GNUNET_PQ_eval_prepared_multi_select (session->conn, - work[i].statement, - params, - work[i].cb, - &rhc); + work[i].statement, + params, + work[i].cb, + &rhc); if ( (0 > qs) || - (GNUNET_OK != rhc.status) ) + (GNUNET_OK != rhc.status) ) break; } if ( (qs < 0) || @@ -3026,8 +3059,8 @@ postgres_test_deposit_done (void *cls, if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs) return GNUNET_DB_STATUS_HARD_ERROR; /* deposit MUST exist */ return (done - ? GNUNET_DB_STATUS_SUCCESS_ONE_RESULT - : GNUNET_DB_STATUS_SUCCESS_NO_RESULTS); + ? GNUNET_DB_STATUS_SUCCESS_ONE_RESULT + : GNUNET_DB_STATUS_SUCCESS_NO_RESULTS); } @@ -3160,7 +3193,7 @@ struct MatchingDepositContext * Plugin context. */ struct PostgresClosure *pg; - + /** * Maximum number of results to return. */ @@ -3201,7 +3234,7 @@ match_deposit_cb (void *cls, mdc->limit); num_results = GNUNET_MIN (num_results, mdc->limit); - for (mdc->i=0;mdc->ii++) + for (mdc->i = 0; mdc->ii++) { struct TALER_Amount amount_with_fee; struct TALER_Amount deposit_fee; @@ -3218,7 +3251,7 @@ match_deposit_cb (void *cls, TALER_PQ_RESULT_SPEC_AMOUNT ("fee_deposit", &deposit_fee), TALER_PQ_result_spec_absolute_time ("wire_deadline", - &wire_deadline), + &wire_deadline), GNUNET_PQ_result_spec_auto_from_type ("h_contract_terms", &h_contract_terms), GNUNET_PQ_result_spec_auto_from_type ("coin_pub", @@ -3269,7 +3302,8 @@ static enum GNUNET_DB_QueryStatus postgres_iterate_matching_deposits (void *cls, struct TALER_EXCHANGEDB_Session *session, const struct GNUNET_HashCode *h_wire, - const struct TALER_MerchantPublicKeyP *merchant_pub, + const struct + TALER_MerchantPublicKeyP *merchant_pub, TALER_EXCHANGEDB_DepositIterator deposit_cb, void *deposit_cb_cls, uint32_t limit) @@ -3372,8 +3406,8 @@ insert_known_coin (void *cls, "Creating known coin %s\n", TALER_B2S (&coin_info->coin_pub)); return GNUNET_PQ_eval_prepared_non_select (session->conn, - "insert_known_coin", - params); + "insert_known_coin", + params); } @@ -3447,8 +3481,8 @@ postgres_ensure_coin_known (void *cls, GNUNET_assert (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs); /* if not known, insert it */ qs = insert_known_coin (pc, - session, - coin); + session, + coin); if (0 >= qs) { if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs) @@ -3496,13 +3530,13 @@ postgres_insert_deposit (void *cls, return qs; #endif GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "Inserting deposit to be executed at %s (%llu/%llu)\n", - GNUNET_STRINGS_absolute_time_to_string (deposit->wire_deadline), - (unsigned long long) deposit->wire_deadline.abs_value_us, - (unsigned long long) deposit->refund_deadline.abs_value_us); + "Inserting deposit to be executed at %s (%llu/%llu)\n", + GNUNET_STRINGS_absolute_time_to_string (deposit->wire_deadline), + (unsigned long long) deposit->wire_deadline.abs_value_us, + (unsigned long long) deposit->refund_deadline.abs_value_us); return GNUNET_PQ_eval_prepared_non_select (session->conn, - "insert_deposit", - params); + "insert_deposit", + params); } @@ -3575,13 +3609,13 @@ struct SelectRefundContext */ static void get_refunds_cb (void *cls, - PGresult *result, - unsigned int num_results) + PGresult *result, + unsigned int num_results) { struct SelectRefundContext *srctx = cls; struct PostgresClosure *pg = srctx->pg; - for (unsigned int i=0;isession.coin.denom_pub_hash), + &refresh_melt->session.coin. + denom_pub_hash), TALER_PQ_RESULT_SPEC_AMOUNT ("fee_refresh", &refresh_melt->melt_fee), GNUNET_PQ_result_spec_rsa_signature ("denom_sig", - &refresh_melt->session.coin.denom_sig.rsa_signature), + &refresh_melt->session.coin.denom_sig. + rsa_signature), GNUNET_PQ_result_spec_uint32 ("noreveal_index", &refresh_melt->session.noreveal_index), GNUNET_PQ_result_spec_auto_from_type ("old_coin_pub", @@ -3710,9 +3747,9 @@ postgres_get_melt (void *cls, if (NULL == session) session = postgres_get_session (pg); qs = GNUNET_PQ_eval_prepared_singleton_select (session->conn, - "get_melt", - params, - rs); + "get_melt", + params, + rs); refresh_melt->session.rc = *rc; return qs; } @@ -3762,7 +3799,8 @@ postgres_get_melt_index (void *cls, static enum GNUNET_DB_QueryStatus postgres_insert_melt (void *cls, struct TALER_EXCHANGEDB_Session *session, - const struct TALER_EXCHANGEDB_RefreshSession *refresh_session) + const struct + TALER_EXCHANGEDB_RefreshSession *refresh_session) { struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (&refresh_session->rc), @@ -3781,8 +3819,8 @@ postgres_insert_melt (void *cls, return qs; #endif return GNUNET_PQ_eval_prepared_non_select (session->conn, - "insert_melt", - params); + "insert_melt", + params); } @@ -3807,7 +3845,8 @@ postgres_insert_refresh_reveal (void *cls, struct TALER_EXCHANGEDB_Session *session, const struct TALER_RefreshCommitmentP *rc, uint32_t num_rrcs, - const struct TALER_EXCHANGEDB_RefreshRevealedCoin *rrcs, + const struct + TALER_EXCHANGEDB_RefreshRevealedCoin *rrcs, unsigned int num_tprivs, const struct TALER_TransferPrivateKeyP *tprivs, const struct TALER_TransferPublicKeyP *tp) @@ -3817,7 +3856,7 @@ postgres_insert_refresh_reveal (void *cls, GNUNET_break (0); return GNUNET_DB_STATUS_HARD_ERROR; } - for (uint32_t i=0;inext; if (NULL != ldl->denom_pub.rsa_public_key) - GNUNET_CRYPTO_rsa_public_key_free (ldl->denom_pub.rsa_public_key); - if (NULL != ldl->ev_sig.rsa_signature) - GNUNET_CRYPTO_rsa_signature_free (ldl->ev_sig.rsa_signature); + GNUNET_CRYPTO_rsa_public_key_free (ldl->denom_pub.rsa_public_key); + if (NULL != ldl->ev_sig.rsa_signature) + GNUNET_CRYPTO_rsa_signature_free (ldl->ev_sig.rsa_signature); GNUNET_free (ldl); ldl = next; } @@ -4291,7 +4332,7 @@ add_coin_deposit (void *cls, { struct CoinHistoryContext *chc = cls; struct PostgresClosure *pg = chc->pg; - + for (unsigned int i = 0; i < num_results; i++) { struct TALER_EXCHANGEDB_Deposit *deposit; @@ -4372,7 +4413,7 @@ add_coin_melt (void *cls, struct CoinHistoryContext *chc = cls; struct PostgresClosure *pg = chc->pg; - for (unsigned int i=0;isession.rc), /* oldcoin_index not needed */ GNUNET_PQ_result_spec_auto_from_type ("old_coin_sig", @@ -4442,7 +4483,7 @@ add_coin_refund (void *cls, struct CoinHistoryContext *chc = cls; struct PostgresClosure *pg = chc->pg; - for (unsigned int i=0;ipg; - for (unsigned int i=0;icoin.denom_pub_hash), GNUNET_PQ_result_spec_rsa_signature ("denom_sig", - &payback->coin.denom_sig.rsa_signature), + &payback->coin.denom_sig. + rsa_signature), GNUNET_PQ_result_spec_end }; @@ -4576,7 +4618,7 @@ add_coin_payback (void *cls, struct CoinHistoryContext *chc = cls; struct PostgresClosure *pg = chc->pg; - for (unsigned int i=0;icoin.denom_pub_hash), GNUNET_PQ_result_spec_rsa_signature ("denom_sig", - &payback->coin.denom_sig.rsa_signature), + &payback->coin.denom_sig. + rsa_signature), GNUNET_PQ_result_spec_end }; @@ -4638,7 +4681,7 @@ add_coin_payback_refresh (void *cls, struct CoinHistoryContext *chc = cls; struct PostgresClosure *pg = chc->pg; - for (unsigned int i=0;icoin.denom_pub_hash), GNUNET_PQ_result_spec_rsa_signature ("denom_sig", - &payback->coin.denom_sig.rsa_signature), + &payback->coin.denom_sig. + rsa_signature), GNUNET_PQ_result_spec_end }; @@ -4714,7 +4758,8 @@ struct Work static enum GNUNET_DB_QueryStatus postgres_get_coin_transactions (void *cls, struct TALER_EXCHANGEDB_Session *session, - const struct TALER_CoinSpendPublicKeyP *coin_pub, + const struct + TALER_CoinSpendPublicKeyP *coin_pub, int include_payback, struct TALER_EXCHANGEDB_TransactionList **tlp) { @@ -4758,7 +4803,7 @@ postgres_get_coin_transactions (void *cls, GNUNET_PQ_query_param_end }; enum GNUNET_DB_QueryStatus qs; - const struct Work * work; + const struct Work *work; work = (GNUNET_YES == include_payback) ? work_wp : work_op; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, @@ -4770,7 +4815,7 @@ postgres_get_coin_transactions (void *cls, chc.session = session; chc.pg = pg; chc.db_cls = cls; - for (unsigned int i=0;NULL != work[i].statement; i++) + for (unsigned int i = 0; NULL != work[i].statement; i++) { qs = GNUNET_PQ_eval_prepared_multi_select (session->conn, work[i].statement, @@ -4778,7 +4823,7 @@ postgres_get_coin_transactions (void *cls, work[i].cb, &chc); if ( (0 > qs) || - (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != chc.status) ) + (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != chc.status) ) { if (NULL != chc.head) common_free_coin_transaction_list (cls, @@ -4840,7 +4885,7 @@ handle_wt_result (void *cls, struct WireTransferResultContext *ctx = cls; struct PostgresClosure *pg = ctx->pg; - for (unsigned int i=0;iconn, - "lookup_deposit_wtid", - params, - rs); + "lookup_deposit_wtid", + params, + rs); if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qs) { cb (cb_cls, @@ -5027,7 +5078,7 @@ postgres_wire_lookup_deposit_wtid (void *cls, if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qs) { /* Ok, we're aware of the transaction, but it has not yet been - executed */ + executed */ cb (cb_cls, NULL, &amount_with_fee, @@ -5052,7 +5103,8 @@ postgres_wire_lookup_deposit_wtid (void *cls, static enum GNUNET_DB_QueryStatus postgres_insert_aggregation_tracking (void *cls, struct TALER_EXCHANGEDB_Session *session, - const struct TALER_WireTransferIdentifierRawP *wtid, + const struct + TALER_WireTransferIdentifierRawP *wtid, unsigned long long deposit_serial_id) { uint64_t rid = deposit_serial_id; @@ -5182,7 +5234,7 @@ postgres_insert_wire_fee (void *cls, } if (0 != TALER_amount_cmp (closing_fee, &cf)) - { + { GNUNET_break (0); return GNUNET_DB_STATUS_HARD_ERROR; } @@ -5247,7 +5299,7 @@ reserve_expired_cb (void *cls, int ret; ret = GNUNET_OK; - for (unsigned int i=0;iconn)); + TALER_LOG_ERROR ( + "Failed to defer wire_out_ref constraint on transaction (%s): %s\n", + PQresStatus (ex), + PQerrorMessage (session->conn)); GNUNET_break (0); PQclear (result); postgres_rollback (cls, @@ -5566,7 +5622,8 @@ static enum GNUNET_DB_QueryStatus postgres_store_wire_transfer_out (void *cls, struct TALER_EXCHANGEDB_Session *session, struct GNUNET_TIME_Absolute date, - const struct TALER_WireTransferIdentifierRawP *wtid, + const struct + TALER_WireTransferIdentifierRawP *wtid, const json_t *wire_account, const char *exchange_account_section, const struct TALER_Amount *amount) @@ -5620,8 +5677,9 @@ postgres_gc (void *cls) be enough _and_ they are tiny so it does not matter to make this tight */ long_ago = GNUNET_TIME_absolute_subtract (now, - GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_YEARS, - 10)); + GNUNET_TIME_relative_multiply ( + GNUNET_TIME_UNIT_YEARS, + 10)); /* FIXME: use GNUNET_PQ_connect_with_cfg instead? */ conn = GNUNET_PQ_connect (pg->connection_cfg_str); if (NULL == conn) @@ -5630,16 +5688,16 @@ postgres_gc (void *cls) if (GNUNET_OK == ret) { if ( - (0 > GNUNET_PQ_eval_prepared_non_select (conn, - "gc_reserves", - params_time)) || - (0 > GNUNET_PQ_eval_prepared_non_select (conn, - "gc_prewire", - params_none)) || - (0 > GNUNET_PQ_eval_prepared_non_select (conn, - "gc_wire_fee", - params_ancient_time)) - ) + (0 > GNUNET_PQ_eval_prepared_non_select (conn, + "gc_reserves", + params_time)) || + (0 > GNUNET_PQ_eval_prepared_non_select (conn, + "gc_prewire", + params_none)) || + (0 > GNUNET_PQ_eval_prepared_non_select (conn, + "gc_wire_fee", + params_ancient_time)) + ) ret = GNUNET_SYSERR; /* This one may fail due to foreign key constraints from payback and reserves_out tables to known_coins; these @@ -5647,8 +5705,8 @@ postgres_gc (void *cls) keys alive for a bit longer, thus causing this statement to fail. */ (void) GNUNET_PQ_eval_prepared_non_select (conn, - "gc_denominations", - params_time); + "gc_denominations", + params_time); } PQfinish (conn); return ret; @@ -5675,7 +5733,7 @@ struct DepositSerialContext * Plugin context. */ struct PostgresClosure *pg; - + /** * Status code, set to #GNUNET_SYSERR on hard errors. */ @@ -5698,8 +5756,8 @@ deposit_serial_helper_cb (void *cls, { struct DepositSerialContext *dsc = cls; struct PostgresClosure *pg = dsc->pg; - - for (unsigned int i=0;ipg; - - for (unsigned int i=0;ipg; - - for (unsigned int i=0;ipg; - - for (unsigned int i=0;ipg; - - for (unsigned int i=0;ipg; - - for (unsigned int i=0;ipg; - - for (unsigned int i=0;iconn, - "payback_get_incr", - params, - &payback_serial_helper_cb, - &psc); + "payback_get_incr", + params, + &payback_serial_helper_cb, + &psc); if (GNUNET_OK != psc.status) return GNUNET_DB_STATUS_HARD_ERROR; return qs; @@ -6748,7 +6823,7 @@ struct PaybackRefreshSerialContext * Plugin context. */ struct PostgresClosure *pg; - + /** * Status code, set to #GNUNET_SYSERR on hard errors. */ @@ -6771,8 +6846,8 @@ payback_refresh_serial_helper_cb (void *cls, { struct PaybackRefreshSerialContext *psc = cls; struct PostgresClosure *pg = psc->pg; - - for (unsigned int i=0;ipg; - - for (unsigned int i=0;istatus = GNUNET_SYSERR; @@ -7405,7 +7497,7 @@ postgres_select_deposits_missing_wire (void *cls, TALER_PQ_query_param_absolute_time (&end_date), GNUNET_PQ_query_param_end }; - struct MissingWireContext mwc = { + struct MissingWireContext mwc = { .cb = cb, .cb_cls = cb_cls, .pg = pg, @@ -7414,10 +7506,10 @@ postgres_select_deposits_missing_wire (void *cls, enum GNUNET_DB_QueryStatus qs; qs = GNUNET_PQ_eval_prepared_multi_select (session->conn, - "deposits_get_overdue", - params, - &missing_wire_cb, - &mwc); + "deposits_get_overdue", + params, + &missing_wire_cb, + &mwc); if (GNUNET_OK != mwc.status) return GNUNET_DB_STATUS_HARD_ERROR; return qs; @@ -7473,7 +7565,8 @@ libtaler_plugin_exchangedb_postgres_init (void *cls) GNUNET_CONFIGURATION_get_value_time (cfg, "exchangedb", "IDLE_RESERVE_EXPIRATION_TIME", - &pg->idle_reserve_expiration_time)) || + &pg->idle_reserve_expiration_time)) + || (GNUNET_OK != GNUNET_CONFIGURATION_get_value_time (cfg, "exchangedb", @@ -7512,7 +7605,8 @@ libtaler_plugin_exchangedb_postgres_init (void *cls) plugin->iterate_denomination_info = &postgres_iterate_denomination_info; plugin->reserve_get = &postgres_reserve_get; plugin->reserves_in_insert = &postgres_reserves_in_insert; - plugin->get_latest_reserve_in_reference = &postgres_get_latest_reserve_in_reference; + plugin->get_latest_reserve_in_reference = + &postgres_get_latest_reserve_in_reference; plugin->get_withdraw_info = &postgres_get_withdraw_info; plugin->insert_withdraw_info = &postgres_insert_withdraw_info; plugin->get_reserve_history = &postgres_get_reserve_history; @@ -7545,7 +7639,8 @@ libtaler_plugin_exchangedb_postgres_init (void *cls) plugin->get_expired_reserves = &postgres_get_expired_reserves; plugin->insert_reserve_closed = &postgres_insert_reserve_closed; plugin->wire_prepare_data_insert = &postgres_wire_prepare_data_insert; - plugin->wire_prepare_data_mark_finished = &postgres_wire_prepare_data_mark_finished; + plugin->wire_prepare_data_mark_finished = + &postgres_wire_prepare_data_mark_finished; plugin->wire_prepare_data_get = &postgres_wire_prepare_data_get; plugin->start_deferred_wire_out = &postgres_start_deferred_wire_out; plugin->store_wire_transfer_out = &postgres_store_wire_transfer_out; diff --git a/src/exchangedb/test_exchangedb.c b/src/exchangedb/test_exchangedb.c index 5018ec63d..7033f728e 100644 --- a/src/exchangedb/test_exchangedb.c +++ b/src/exchangedb/test_exchangedb.c @@ -35,7 +35,7 @@ static int result; */ #define FAILIF(cond) \ do { \ - if (!(cond)){ break;} \ + if (! (cond)) { break;} \ GNUNET_break (0); \ goto drop; \ } while (0) @@ -136,7 +136,7 @@ test_wire_prepare (struct TALER_EXCHANGEDB_Session *session) &dead_prepare_cb, NULL)); return GNUNET_OK; - drop: + drop: return GNUNET_SYSERR; } @@ -171,7 +171,7 @@ check_reserve (struct TALER_EXCHANGEDB_Session *session, FAILIF (0 != strcmp (currency, reserve.balance.currency)); return GNUNET_OK; - drop: + drop: return GNUNET_SYSERR; } @@ -238,16 +238,18 @@ create_denom_key_pair (unsigned int size, GNUNET_TIME_round_abs (&now); dki.issue.properties.start = GNUNET_TIME_absolute_hton (now); dki.issue.properties.expire_withdraw = GNUNET_TIME_absolute_hton - (GNUNET_TIME_absolute_add (now, - GNUNET_TIME_UNIT_HOURS)); + (GNUNET_TIME_absolute_add (now, + GNUNET_TIME_UNIT_HOURS)); dki.issue.properties.expire_deposit = GNUNET_TIME_absolute_hton - (GNUNET_TIME_absolute_add - (now, - GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_HOURS, 2))); + (GNUNET_TIME_absolute_add + (now, + GNUNET_TIME_relative_multiply ( + GNUNET_TIME_UNIT_HOURS, 2))); dki.issue.properties.expire_legal = GNUNET_TIME_absolute_hton - (GNUNET_TIME_absolute_add - (now, - GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_HOURS, 3))); + (GNUNET_TIME_absolute_add + (now, + GNUNET_TIME_relative_multiply ( + GNUNET_TIME_UNIT_HOURS, 3))); TALER_amount_hton (&dki.issue.properties.value, value); TALER_amount_hton (&dki.issue.properties.fee_withdraw, fee_withdraw); TALER_amount_hton (&dki.issue.properties.fee_deposit, fee_deposit); @@ -256,15 +258,17 @@ create_denom_key_pair (unsigned int size, GNUNET_CRYPTO_rsa_public_key_hash (dkp->pub.rsa_public_key, &dki.issue.properties.denom_hash); - dki.issue.properties.purpose.size = htonl (sizeof (struct TALER_DenominationKeyValidityPS)); - dki.issue.properties.purpose.purpose = htonl (TALER_SIGNATURE_MASTER_DENOMINATION_KEY_VALIDITY); + dki.issue.properties.purpose.size = htonl (sizeof (struct + TALER_DenominationKeyValidityPS)); + dki.issue.properties.purpose.purpose = htonl ( + TALER_SIGNATURE_MASTER_DENOMINATION_KEY_VALIDITY); if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != plugin->insert_denomination_info (plugin->cls, session, &dki.denom_pub, &dki.issue)) { - GNUNET_break(0); + GNUNET_break (0); destroy_denom_key_pair (dkp); return NULL; } @@ -274,14 +278,14 @@ create_denom_key_pair (unsigned int size, &dki.issue.properties.denom_hash, &issue2)) { - GNUNET_break(0); + GNUNET_break (0); destroy_denom_key_pair (dkp); return NULL; } if (0 != GNUNET_memcmp (&dki.issue, &issue2)) { - GNUNET_break(0); + GNUNET_break (0); destroy_denom_key_pair (dkp); return NULL; } @@ -358,7 +362,8 @@ never_called_cb (void *cls, static void check_refresh_reveal_cb (void *cls, uint32_t num_newcoins, - const struct TALER_EXCHANGEDB_RefreshRevealedCoin *rrcs, + const struct + TALER_EXCHANGEDB_RefreshRevealedCoin *rrcs, unsigned int num_tprivs, const struct TALER_TransferPrivateKeyP *tprivsr, const struct TALER_TransferPublicKeyP *tpr) @@ -366,7 +371,8 @@ check_refresh_reveal_cb (void *cls, /* compare the refresh commit coin arrays */ for (unsigned int cnt = 0; cnt < num_newcoins; cnt++) { - const struct TALER_EXCHANGEDB_RefreshRevealedCoin *acoin = &revealed_coins[cnt]; + const struct TALER_EXCHANGEDB_RefreshRevealedCoin *acoin = + &revealed_coins[cnt]; const struct TALER_EXCHANGEDB_RefreshRevealedCoin *bcoin = &rrcs[cnt]; GNUNET_assert (acoin->coin_ev_size == bcoin->coin_ev_size); @@ -374,13 +380,15 @@ check_refresh_reveal_cb (void *cls, GNUNET_memcmp (acoin->coin_ev, bcoin->coin_ev)); GNUNET_assert (0 == - GNUNET_CRYPTO_rsa_public_key_cmp (acoin->denom_pub.rsa_public_key, - bcoin->denom_pub.rsa_public_key)); + GNUNET_CRYPTO_rsa_public_key_cmp ( + acoin->denom_pub.rsa_public_key, + bcoin->denom_pub. + rsa_public_key)); } - GNUNET_assert(0 == GNUNET_memcmp(&tpub, tpr)); - GNUNET_assert(0 == memcmp(tprivs, tprivsr, - sizeof(struct TALER_TransferPrivateKeyP) * - (TALER_CNC_KAPPA - 1))); + GNUNET_assert (0 == GNUNET_memcmp (&tpub, tpr)); + GNUNET_assert (0 == memcmp (tprivs, tprivsr, + sizeof(struct TALER_TransferPrivateKeyP) + * (TALER_CNC_KAPPA - 1))); } @@ -448,15 +456,17 @@ handle_link_data_cb (void *cls, int found; found = GNUNET_NO; - for (unsigned int cnt=0;cnt < MELT_NEW_COINS;cnt++) + for (unsigned int cnt = 0; cnt < MELT_NEW_COINS; cnt++) { GNUNET_assert (NULL != ldlp->ev_sig.rsa_signature); if ( (0 == GNUNET_CRYPTO_rsa_public_key_cmp (ldlp->denom_pub.rsa_public_key, - new_dkp[cnt]->pub.rsa_public_key)) && + new_dkp[cnt]->pub.rsa_public_key)) + && (0 == GNUNET_CRYPTO_rsa_signature_cmp (ldlp->ev_sig.rsa_signature, - revealed_coins[cnt].coin_sig.rsa_signature)) ) + revealed_coins[cnt].coin_sig. + rsa_signature)) ) { found = GNUNET_YES; break; @@ -502,7 +512,7 @@ test_melting (struct TALER_EXCHANGEDB_Session *session) &fee_withdraw, &fee_deposit, &fee_refresh, - &fee_refund); + &fee_refund); GNUNET_assert (NULL != dkp); /* initialize refresh session melt data */ { @@ -513,8 +523,8 @@ test_melting (struct TALER_EXCHANGEDB_Session *session) sizeof (refresh_session.coin.coin_pub), &hc); refresh_session.coin.denom_sig.rsa_signature = - GNUNET_CRYPTO_rsa_sign_fdh (dkp->priv.rsa_private_key, - &hc); + GNUNET_CRYPTO_rsa_sign_fdh (dkp->priv.rsa_private_key, + &hc); GNUNET_assert (NULL != refresh_session.coin.denom_sig.rsa_signature); GNUNET_CRYPTO_rsa_public_key_hash (dkp->pub.rsa_public_key, &refresh_session.coin.denom_pub_hash); @@ -532,11 +542,11 @@ test_melting (struct TALER_EXCHANGEDB_Session *session) session, &refresh_session.coin)); FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != - plugin->insert_melt (plugin->cls, + plugin->insert_melt (plugin->cls, session, &refresh_session)); FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != - plugin->get_melt (plugin->cls, + plugin->get_melt (plugin->cls, session, &refresh_session.rc, &ret_refresh_session)); @@ -548,29 +558,32 @@ test_melting (struct TALER_EXCHANGEDB_Session *session) FAILIF (0 != TALER_amount_cmp (&fee_refresh, &ret_refresh_session.melt_fee)); - FAILIF(0 != - GNUNET_memcmp(&refresh_session.rc, &ret_refresh_session.session.rc)); - FAILIF(0 != GNUNET_memcmp(&refresh_session.coin_sig, - &ret_refresh_session.session.coin_sig)); FAILIF (0 != - GNUNET_CRYPTO_rsa_signature_cmp (refresh_session.coin.denom_sig.rsa_signature, - ret_refresh_session.session.coin.denom_sig.rsa_signature)); + GNUNET_memcmp (&refresh_session.rc, &ret_refresh_session.session.rc)); + FAILIF (0 != GNUNET_memcmp (&refresh_session.coin_sig, + &ret_refresh_session.session.coin_sig)); + FAILIF (0 != + GNUNET_CRYPTO_rsa_signature_cmp ( + refresh_session.coin.denom_sig.rsa_signature, + ret_refresh_session.session.coin. + denom_sig.rsa_signature)); FAILIF (0 != memcmp (&refresh_session.coin.coin_pub, &ret_refresh_session.session.coin.coin_pub, sizeof (refresh_session.coin.coin_pub))); FAILIF (0 != GNUNET_memcmp (&refresh_session.coin.denom_pub_hash, &ret_refresh_session.session.coin.denom_pub_hash)); - GNUNET_CRYPTO_rsa_signature_free (ret_refresh_session.session.coin.denom_sig.rsa_signature); + GNUNET_CRYPTO_rsa_signature_free ( + ret_refresh_session.session.coin.denom_sig.rsa_signature); /* test 'select_refreshs_above_serial_id' */ auditor_row_cnt = 0; FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != - plugin->select_refreshs_above_serial_id (plugin->cls, - session, - 0, - &audit_refresh_session_cb, - NULL)); + plugin->select_refreshs_above_serial_id (plugin->cls, + session, + 0, + &audit_refresh_session_cb, + NULL)); FAILIF (1 != auditor_row_cnt); new_dkp = GNUNET_new_array (MELT_NEW_COINS, @@ -580,7 +593,7 @@ test_melting (struct TALER_EXCHANGEDB_Session *session) revealed_coins = GNUNET_new_array (MELT_NEW_COINS, struct TALER_EXCHANGEDB_RefreshRevealedCoin); - for (unsigned int cnt=0; cnt < MELT_NEW_COINS; cnt++) + for (unsigned int cnt = 0; cnt < MELT_NEW_COINS; cnt++) { struct TALER_EXCHANGEDB_RefreshRevealedCoin *ccoin; struct GNUNET_HashCode hc; @@ -595,12 +608,13 @@ test_melting (struct TALER_EXCHANGEDB_Session *session) &fee_withdraw, &fee_deposit, &fee_refresh, - &fee_refund); + &fee_refund); GNUNET_assert (NULL != new_dkp[cnt]); new_denom_pubs[cnt] = new_dkp[cnt]->pub; ccoin = &revealed_coins[cnt]; - ccoin->coin_ev_size = (size_t) GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, - COIN_ENC_MAX_SIZE); + ccoin->coin_ev_size = (size_t) GNUNET_CRYPTO_random_u64 ( + GNUNET_CRYPTO_QUALITY_WEAK, + COIN_ENC_MAX_SIZE); ccoin->coin_ev = GNUNET_malloc (ccoin->coin_ev_size); GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK, ccoin->coin_ev, @@ -651,7 +665,7 @@ test_melting (struct TALER_EXCHANGEDB_Session *session) session, &refresh_session.coin.coin_pub, GNUNET_YES, - &tl); + &tl); FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != qs); plugin->free_coin_transaction_list (plugin->cls, tl); @@ -659,20 +673,22 @@ test_melting (struct TALER_EXCHANGEDB_Session *session) ret = GNUNET_OK; - drop: + drop: if (NULL != revealed_coins) { - for (unsigned int cnt=0; cnt < MELT_NEW_COINS; cnt++) + for (unsigned int cnt = 0; cnt < MELT_NEW_COINS; cnt++) { if (NULL != revealed_coins[cnt].coin_sig.rsa_signature) - GNUNET_CRYPTO_rsa_signature_free (revealed_coins[cnt].coin_sig.rsa_signature); + GNUNET_CRYPTO_rsa_signature_free ( + revealed_coins[cnt].coin_sig.rsa_signature); GNUNET_free (revealed_coins[cnt].coin_ev); } GNUNET_free (revealed_coins); revealed_coins = NULL; } destroy_denom_key_pair (dkp); - GNUNET_CRYPTO_rsa_signature_free (refresh_session.coin.denom_sig.rsa_signature); + GNUNET_CRYPTO_rsa_signature_free ( + refresh_session.coin.denom_sig.rsa_signature); GNUNET_free_non_null (new_denom_pubs); for (unsigned int cnt = 0; (NULL != new_dkp) && (cnt < MELT_NEW_COINS) && (NULL != new_dkp[cnt]); @@ -1000,8 +1016,9 @@ test_gc (struct TALER_EXCHANGEDB_Session *session) now = GNUNET_TIME_absolute_get (); GNUNET_TIME_round_abs (&now); past = GNUNET_TIME_absolute_subtract (now, - GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_HOURS, - 4)); + GNUNET_TIME_relative_multiply ( + GNUNET_TIME_UNIT_HOURS, + 4)); dkp = create_denom_key_pair (1024, session, past, @@ -1014,12 +1031,12 @@ test_gc (struct TALER_EXCHANGEDB_Session *session) if (GNUNET_OK != plugin->gc (plugin->cls)) { - GNUNET_break(0); + GNUNET_break (0); destroy_denom_key_pair (dkp); return GNUNET_SYSERR; } - GNUNET_CRYPTO_rsa_public_key_hash (dkp->pub.rsa_public_key, - &denom_hash); + GNUNET_CRYPTO_rsa_public_key_hash (dkp->pub.rsa_public_key, + &denom_hash); if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS != plugin->get_denomination_info (plugin->cls, @@ -1027,7 +1044,7 @@ test_gc (struct TALER_EXCHANGEDB_Session *session) &denom_hash, &issue2)) { - GNUNET_break(0); + GNUNET_break (0); destroy_denom_key_pair (dkp); return GNUNET_SYSERR; } @@ -1076,7 +1093,7 @@ test_wire_fees (struct TALER_EXCHANGEDB_Session *session) start_date, end_date, &wire_fee, - &closing_fee, + &closing_fee, &master_sig)) { GNUNET_break (0); @@ -1089,7 +1106,7 @@ test_wire_fees (struct TALER_EXCHANGEDB_Session *session) start_date, end_date, &wire_fee, - &closing_fee, + &closing_fee, &master_sig)) { GNUNET_break (0); @@ -1105,7 +1122,7 @@ test_wire_fees (struct TALER_EXCHANGEDB_Session *session) &sd, &ed, &fee, - &fee2, + &fee2, &ms)) { GNUNET_break (0); @@ -1119,7 +1136,7 @@ test_wire_fees (struct TALER_EXCHANGEDB_Session *session) &sd, &ed, &fee, - &fee2, + &fee2, &ms)) { GNUNET_break (0); @@ -1141,7 +1158,7 @@ test_wire_fees (struct TALER_EXCHANGEDB_Session *session) } -static struct TALER_Amount wire_out_amount; +static struct TALER_Amount wire_out_amount; /** @@ -1248,7 +1265,8 @@ test_wire_out (struct TALER_EXCHANGEDB_Session *session, json_t *wire_out_account; wire_out_account = json_pack ("{s:s,s:s}", - "url", "payto://x-taler-bank/localhost:8080/1", + "url", + "payto://x-taler-bank/localhost:8080/1", "salt", "this-is-my-salt"); if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != plugin->store_wire_transfer_out (plugin->cls, @@ -1293,7 +1311,7 @@ test_wire_out (struct TALER_EXCHANGEDB_Session *session, FAILIF (1 != auditor_row_cnt); return GNUNET_OK; - drop: + drop: return GNUNET_SYSERR; } @@ -1327,7 +1345,7 @@ payback_cb (void *cls, FAILIF (0 != GNUNET_memcmp (cb, coin_blind)); return GNUNET_OK; - drop: + drop: return GNUNET_SYSERR; } @@ -1412,12 +1430,12 @@ wire_missing_cb (void *cls, */ static int check_refund_cb (void *cls, - const struct TALER_MerchantPublicKeyP *merchant_pub, - const struct TALER_MerchantSignatureP *merchant_sig, - const struct GNUNET_HashCode *h_contract, - uint64_t rtransaction_id, - const struct TALER_Amount *amount_with_fee, - const struct TALER_Amount *refund_fee) + const struct TALER_MerchantPublicKeyP *merchant_pub, + const struct TALER_MerchantSignatureP *merchant_sig, + const struct GNUNET_HashCode *h_contract, + uint64_t rtransaction_id, + const struct TALER_Amount *amount_with_fee, + const struct TALER_Amount *refund_fee) { const struct TALER_EXCHANGEDB_Refund *refund = cls; @@ -1445,13 +1463,13 @@ check_refund_cb (void *cls, result = 66; } if (0 != TALER_amount_cmp (amount_with_fee, - &refund->refund_amount)) + &refund->refund_amount)) { GNUNET_break (0); result = 66; } if (0 != TALER_amount_cmp (refund_fee, - &refund->refund_fee)) + &refund->refund_fee)) { GNUNET_break (0); result = 66; @@ -1601,7 +1619,7 @@ run (void *cls) &reserve_pub, &value, now, - sndr, + sndr, "account-1", "TEST2", 5)); @@ -1637,12 +1655,12 @@ run (void *cls) &fee_withdraw, &fee_deposit, &fee_refresh, - &fee_refund); + &fee_refund); GNUNET_assert (NULL != dkp); GNUNET_CRYPTO_rsa_public_key_hash (dkp->pub.rsa_public_key, &dkp_pub_hash); - RND_BLK(&cbc.h_coin_envelope); - RND_BLK(&cbc.reserve_sig); + RND_BLK (&cbc.h_coin_envelope); + RND_BLK (&cbc.reserve_sig); cbc.denom_pub_hash = dkp_pub_hash; cbc.sig.rsa_signature = GNUNET_CRYPTO_rsa_sign_fdh (dkp->priv.rsa_private_key, @@ -1675,8 +1693,8 @@ run (void *cls) session, &cbc.h_coin_envelope, &cbc2)); - FAILIF(0 != GNUNET_memcmp(&cbc2.reserve_sig, &cbc.reserve_sig)); - FAILIF(0 != GNUNET_memcmp(&cbc2.reserve_pub, &cbc.reserve_pub)); + FAILIF (0 != GNUNET_memcmp (&cbc2.reserve_sig, &cbc.reserve_sig)); + FAILIF (0 != GNUNET_memcmp (&cbc2.reserve_pub, &cbc.reserve_pub)); result = 6; FAILIF (GNUNET_OK != GNUNET_CRYPTO_rsa_verify (&cbc.h_coin_envelope, @@ -1714,39 +1732,39 @@ run (void *cls) &coin_blind)); GNUNET_assert (GNUNET_OK == - TALER_amount_add (&amount_with_fee, - &value, - &value)); + TALER_amount_add (&amount_with_fee, + &value, + &value)); GNUNET_assert (GNUNET_OK == TALER_string_to_amount (CURRENCY ":0.000010", &fee_closing)); now = GNUNET_TIME_absolute_get (); (void) GNUNET_TIME_round_abs (&now); FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != - plugin->insert_reserve_closed (plugin->cls, - session, - &reserve_pub, - now, - sndr, - &wire_out_wtid, - &amount_with_fee, - &fee_closing)); + plugin->insert_reserve_closed (plugin->cls, + session, + &reserve_pub, + now, + sndr, + &wire_out_wtid, + &amount_with_fee, + &fee_closing)); FAILIF (GNUNET_OK != check_reserve (session, &reserve_pub, - 0, - 0, + 0, + 0, value.currency)); result = 7; qs = plugin->get_reserve_history (plugin->cls, session, &reserve_pub, - &rh); + &rh); FAILIF (0 > qs); FAILIF (NULL == rh); rh_head = rh; - for (cnt=0; NULL != rh_head; rh_head=rh_head->next, cnt++) + for (cnt = 0; NULL != rh_head; rh_head = rh_head->next, cnt++) { switch (rh_head->type) { @@ -1793,7 +1811,7 @@ run (void *cls) case TALER_EXCHANGEDB_RO_EXCHANGE_TO_BANK: { struct TALER_EXCHANGEDB_ClosingTransfer *closing - = rh_head->details.closing; + = rh_head->details.closing; FAILIF (0 != memcmp (&closing->reserve_pub, &reserve_pub, @@ -1811,16 +1829,16 @@ run (void *cls) auditor_row_cnt = 0; FAILIF (0 >= plugin->select_reserves_in_above_serial_id (plugin->cls, - session, - 0, - &audit_reserve_in_cb, - NULL)); + session, + 0, + &audit_reserve_in_cb, + NULL)); FAILIF (0 >= plugin->select_reserves_out_above_serial_id (plugin->cls, - session, - 0, - &audit_reserve_out_cb, - NULL)); + session, + 0, + &audit_reserve_out_cb, + NULL)); FAILIF (3 != auditor_row_cnt); /* Tests for deposits */ @@ -1877,10 +1895,10 @@ run (void *cls) auditor_row_cnt = 0; FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != plugin->select_deposits_above_serial_id (plugin->cls, - session, - 0, - &audit_deposit_cb, - NULL)); + session, + 0, + &audit_deposit_cb, + NULL)); FAILIF (1 != auditor_row_cnt); result = 9; FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != @@ -1906,7 +1924,7 @@ run (void *cls) "test-2")); FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != plugin->mark_deposit_tiny (plugin->cls, - session, + session, deposit_rowid)); FAILIF (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS != plugin->get_ready_deposit (plugin->cls, @@ -1960,7 +1978,7 @@ run (void *cls) &deposit2, GNUNET_YES)); FAILIF (GNUNET_OK != - test_melting (session)); + test_melting (session)); FAILIF (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS != plugin->commit (plugin->cls, session)); @@ -1972,7 +1990,7 @@ run (void *cls) RND_BLK (&refund.merchant_sig); refund.h_contract_terms = deposit.h_contract_terms; refund.rtransaction_id = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, - UINT64_MAX); + UINT64_MAX); refund.refund_amount = deposit.amount_with_fee; refund.refund_fee = fee_refund; FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != @@ -1980,11 +1998,11 @@ run (void *cls) session, &refund)); FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != - plugin->select_refunds_by_coin (plugin->cls, - session, - &refund.coin.coin_pub, - &check_refund_cb, - &refund)); + plugin->select_refunds_by_coin (plugin->cls, + session, + &refund.coin.coin_pub, + &check_refund_cb, + &refund)); /* test payback / revocation */ RND_BLK (&master_sig); @@ -2024,7 +2042,7 @@ run (void *cls) session, &dkp_pub_hash, &msig, - &rev_rowid)); + &rev_rowid)); FAILIF (0 != GNUNET_memcmp (&msig, &master_sig)); } @@ -2046,17 +2064,17 @@ run (void *cls) auditor_row_cnt = 0; FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != plugin->select_refunds_above_serial_id (plugin->cls, - session, - 0, - &audit_refund_cb, - NULL)); + session, + 0, + &audit_refund_cb, + NULL)); FAILIF (1 != auditor_row_cnt); qs = plugin->get_coin_transactions (plugin->cls, session, &refund.coin.coin_pub, GNUNET_YES, - &tl); + &tl); FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != qs); GNUNET_assert (NULL != tl); matched = 0; @@ -2088,8 +2106,10 @@ run (void *cls) sizeof (struct GNUNET_HashCode))); /* Note: not comparing 'wire', seems truly redundant and would be tricky */ FAILIF (have->timestamp.abs_value_us != deposit.timestamp.abs_value_us); - FAILIF (have->refund_deadline.abs_value_us != deposit.refund_deadline.abs_value_us); - FAILIF (have->wire_deadline.abs_value_us != deposit.wire_deadline.abs_value_us); + FAILIF (have->refund_deadline.abs_value_us != + deposit.refund_deadline.abs_value_us); + FAILIF (have->wire_deadline.abs_value_us != + deposit.wire_deadline.abs_value_us); FAILIF (0 != TALER_amount_cmp (&have->amount_with_fee, &deposit.amount_with_fee)); FAILIF (0 != TALER_amount_cmp (&have->deposit_fee, @@ -2098,7 +2118,7 @@ run (void *cls) break; } #if 0 - /* this coin pub was actually never melted... */ + /* this coin pub was actually never melted... */ case TALER_EXCHANGEDB_TT_REFRESH_MELT: FAILIF (0 != memcmp (&melt, &tlp->details.melt, @@ -2175,7 +2195,7 @@ run (void *cls) result = 0; - drop: + drop: if ( (0 != result) && (NULL != session) ) plugin->rollback (plugin->cls, @@ -2220,10 +2240,10 @@ main (int argc, plugin_name++; (void) GNUNET_asprintf (&testname, "test-exchange-db-%s", - plugin_name); + plugin_name); (void) GNUNET_asprintf (&config_filename, "%s.conf", - testname); + testname); cfg = GNUNET_CONFIGURATION_create (); if (GNUNET_OK != GNUNET_CONFIGURATION_parse (cfg, @@ -2235,7 +2255,7 @@ main (int argc, return 2; } GNUNET_SCHEDULER_run (&run, - cfg); + cfg); GNUNET_CONFIGURATION_destroy (cfg); GNUNET_free (config_filename); GNUNET_free (testname); diff --git a/src/exchangedb/test_exchangedb_auditors.c b/src/exchangedb/test_exchangedb_auditors.c index 9424919c4..4c50d09ab 100644 --- a/src/exchangedb/test_exchangedb_auditors.c +++ b/src/exchangedb/test_exchangedb_auditors.c @@ -156,7 +156,7 @@ main (int argc, &auditor_cb, NULL)); ret = 0; - EXITIF_exit: + EXITIF_exit: if (NULL != tmpdir) { (void) GNUNET_DISK_directory_remove (tmpdir); diff --git a/src/exchangedb/test_exchangedb_denomkeys.c b/src/exchangedb/test_exchangedb_denomkeys.c index a8e7af04d..8b0c9c04e 100644 --- a/src/exchangedb/test_exchangedb_denomkeys.c +++ b/src/exchangedb/test_exchangedb_denomkeys.c @@ -140,13 +140,15 @@ main (int argc, GNUNET_free (pk); GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK, &dki.issue, - sizeof (struct TALER_EXCHANGEDB_DenominationKeyInformationP)); + sizeof (struct + TALER_EXCHANGEDB_DenominationKeyInformationP)); dki.denom_priv.rsa_private_key = GNUNET_CRYPTO_rsa_private_key_create (RSA_KEY_SIZE); dki.denom_pub.rsa_public_key = GNUNET_CRYPTO_rsa_private_key_get_public (dki.denom_priv.rsa_private_key); - enc_size = GNUNET_CRYPTO_rsa_private_key_encode (dki.denom_priv.rsa_private_key, - &enc); + enc_size = GNUNET_CRYPTO_rsa_private_key_encode ( + dki.denom_priv.rsa_private_key, + &enc); EXITIF (NULL == (tmpdir = GNUNET_DISK_mkdtemp ("test_exchangedb_dki"))); start = GNUNET_TIME_absolute_ntoh (dki.issue.properties.start); GNUNET_asprintf (&tmpfile, @@ -172,24 +174,26 @@ main (int argc, EXITIF (GNUNET_OK != TALER_EXCHANGEDB_denomination_key_revoke (revdir, - &dki.issue.properties.denom_hash, + &dki.issue.properties. + denom_hash, &master_priv)); EXITIF (1 != TALER_EXCHANGEDB_revocations_iterate (revdir, - &master_pub, - &dki_iter_revoked, - &dki)); + &master_pub, + &dki_iter_revoked, + &dki)); GNUNET_free (revdir); - enc_read_size = GNUNET_CRYPTO_rsa_private_key_encode (dki_read.denom_priv.rsa_private_key, - &enc_read); + enc_read_size = GNUNET_CRYPTO_rsa_private_key_encode ( + dki_read.denom_priv.rsa_private_key, + &enc_read); EXITIF (enc_size != enc_read_size); EXITIF (0 != memcmp (enc, enc_read, enc_size)); ret = 0; - EXITIF_exit: + EXITIF_exit: GNUNET_free_non_null (enc); GNUNET_free_non_null (tmpfile); if (NULL != tmpdir) diff --git a/src/exchangedb/test_exchangedb_signkeys.c b/src/exchangedb/test_exchangedb_signkeys.c index 9ff423082..99d65e26f 100644 --- a/src/exchangedb/test_exchangedb_signkeys.c +++ b/src/exchangedb/test_exchangedb_signkeys.c @@ -73,7 +73,8 @@ main (int argc, NULL); GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK, &ski, - sizeof (struct TALER_EXCHANGEDB_PrivateSigningKeyInformationP)); + sizeof (struct + TALER_EXCHANGEDB_PrivateSigningKeyInformationP)); now = GNUNET_TIME_absolute_get (); EXITIF (NULL == (tmpfile = GNUNET_DISK_mkdtemp ("test_exchangedb_ski"))); EXITIF (GNUNET_OK != @@ -85,7 +86,7 @@ main (int argc, &ski_iter, &ski)); ret = 0; - EXITIF_exit: + EXITIF_exit: if (NULL != tmpfile) { (void) GNUNET_DISK_directory_remove (tmpfile); diff --git a/src/exchangedb/test_perf_taler_exchangedb.c b/src/exchangedb/test_perf_taler_exchangedb.c index 0f93c7089..ad8e630d4 100644 --- a/src/exchangedb/test_perf_taler_exchangedb.c +++ b/src/exchangedb/test_perf_taler_exchangedb.c @@ -52,7 +52,7 @@ test_allocate () dki = PERF_TALER_EXCHANGEDB_denomination_init (); reserve = PERF_TALER_EXCHANGEDB_reserve_init (); coin = PERF_TALER_EXCHANGEDB_coin_init (dki, - reserve); + reserve); deposit = PERF_TALER_EXCHANGEDB_deposit_init (coin); dki_copy = PERF_TALER_EXCHANGEDB_denomination_copy (dki); @@ -76,99 +76,100 @@ test_allocate () * and logs the results using Gauger */ int -main (int argc, char ** argv) +main (int argc, char **argv) { int ret = 0; - struct PERF_TALER_EXCHANGEDB_Cmd init[] = - { + struct PERF_TALER_EXCHANGEDB_Cmd init[] = { PERF_TALER_EXCHANGEDB_INIT_CMD_END ("init") }; - struct PERF_TALER_EXCHANGEDB_Cmd benchmark[] = - { + struct PERF_TALER_EXCHANGEDB_Cmd benchmark[] = { // Denomination used to create coins PERF_TALER_EXCHANGEDB_INIT_CMD_DEBUG ("00 - Start of interpreter"), PERF_TALER_EXCHANGEDB_INIT_CMD_LOOP ("01 - denomination loop", - NB_DENOMINATION_INIT), + NB_DENOMINATION_INIT), PERF_TALER_EXCHANGEDB_INIT_CMD_START_TRANSACTION ("01 - start transaction"), PERF_TALER_EXCHANGEDB_INIT_CMD_CREATE_DENOMINATION ("01 - denomination"), PERF_TALER_EXCHANGEDB_INIT_CMD_INSERT_DENOMINATION ("01 - insert", - "01 - denomination"), - PERF_TALER_EXCHANGEDB_INIT_CMD_COMMIT_TRANSACTION ("01 - commit transaction"), + "01 - denomination"), + PERF_TALER_EXCHANGEDB_INIT_CMD_COMMIT_TRANSACTION ( + "01 - commit transaction"), PERF_TALER_EXCHANGEDB_INIT_CMD_SAVE_ARRAY ("01 - save denomination", - "01 - denomination loop", - "01 - denomination", - NB_DENOMINATION_SAVE), + "01 - denomination loop", + "01 - denomination", + NB_DENOMINATION_SAVE), PERF_TALER_EXCHANGEDB_INIT_CMD_END_LOOP ("01 - denomination loop end", - "01 - denomination loop"), + "01 - denomination loop"), PERF_TALER_EXCHANGEDB_INIT_CMD_DEBUG ("01 - init denomination complete"), // End of initialization // Reserve initialization PERF_TALER_EXCHANGEDB_INIT_CMD_LOOP ("02 - init reserve loop", - NB_RESERVE_INIT), + NB_RESERVE_INIT), PERF_TALER_EXCHANGEDB_INIT_CMD_CREATE_RESERVE ("02 - reserve"), PERF_TALER_EXCHANGEDB_INIT_CMD_INSERT_RESERVE ("02 - insert", - "02 - reserve"), + "02 - reserve"), PERF_TALER_EXCHANGEDB_INIT_CMD_SAVE_ARRAY ("02 - save reserve", - "02 - init reserve loop", - "02 - reserve", - NB_RESERVE_SAVE), + "02 - init reserve loop", + "02 - reserve", + NB_RESERVE_SAVE), PERF_TALER_EXCHANGEDB_INIT_CMD_END_LOOP ("02 - init reserve end loop", - "02 - init reserve loop"), + "02 - init reserve loop"), PERF_TALER_EXCHANGEDB_INIT_CMD_DEBUG ("02 - reserve init complete"), // End reserve init // Withdrawal initialization PERF_TALER_EXCHANGEDB_INIT_CMD_LOOP ("03 - init withdraw loop", - NB_WITHDRAW_INIT), + NB_WITHDRAW_INIT), PERF_TALER_EXCHANGEDB_INIT_CMD_START_TRANSACTION ("03 - start transaction"), PERF_TALER_EXCHANGEDB_INIT_CMD_LOAD_ARRAY ("03 - denomination load", - "03 - init withdraw loop", - "01 - save denomination"), + "03 - init withdraw loop", + "01 - save denomination"), PERF_TALER_EXCHANGEDB_INIT_CMD_LOAD_ARRAY ("03 - reserve load", - "03 - init withdraw loop", - "02 - save reserve"), + "03 - init withdraw loop", + "02 - save reserve"), PERF_TALER_EXCHANGEDB_INIT_CMD_CREATE_WITHDRAW ("03 - withdraw", - "03 - denomination load", - "03 - reserve load"), + "03 - denomination load", + "03 - reserve load"), PERF_TALER_EXCHANGEDB_INIT_CMD_INSERT_WITHDRAW ("03 - insert withdraw", - "03 - withdraw"), - PERF_TALER_EXCHANGEDB_INIT_CMD_COMMIT_TRANSACTION ("03 - commit transaction"), + "03 - withdraw"), + PERF_TALER_EXCHANGEDB_INIT_CMD_COMMIT_TRANSACTION ( + "03 - commit transaction"), PERF_TALER_EXCHANGEDB_INIT_CMD_SAVE_ARRAY ("03 - coin array", - "03 - init withdraw loop", - "03 - withdraw", - NB_WITHDRAW_SAVE), + "03 - init withdraw loop", + "03 - withdraw", + NB_WITHDRAW_SAVE), PERF_TALER_EXCHANGEDB_INIT_CMD_END_LOOP ("03 - withdraw init end loop", - "03 - init withdraw loop"), + "03 - init withdraw loop"), PERF_TALER_EXCHANGEDB_INIT_CMD_DEBUG ("03 - withdraw init complete"), - //End of withdrawal initialization - //Deposit initialization + // End of withdrawal initialization + // Deposit initialization PERF_TALER_EXCHANGEDB_INIT_CMD_GET_TIME ("04 - time start"), PERF_TALER_EXCHANGEDB_INIT_CMD_LOOP ("04 - deposit init loop", - NB_DEPOSIT_INIT), + NB_DEPOSIT_INIT), PERF_TALER_EXCHANGEDB_INIT_CMD_START_TRANSACTION ("04 - start transaction"), PERF_TALER_EXCHANGEDB_INIT_CMD_LOAD_ARRAY ("04 - coin load", - "04 - deposit init loop", - "03 - coin array"), + "04 - deposit init loop", + "03 - coin array"), PERF_TALER_EXCHANGEDB_INIT_CMD_CREATE_DEPOSIT ("04 - deposit", - "04 - coin load"), + "04 - coin load"), PERF_TALER_EXCHANGEDB_INIT_CMD_INSERT_DEPOSIT ("04 - insert deposit", - "04 - deposit"), - PERF_TALER_EXCHANGEDB_INIT_CMD_COMMIT_TRANSACTION ("04 - commit transaction"), + "04 - deposit"), + PERF_TALER_EXCHANGEDB_INIT_CMD_COMMIT_TRANSACTION ( + "04 - commit transaction"), PERF_TALER_EXCHANGEDB_INIT_CMD_SAVE_ARRAY ("04 - deposit array", - "04 - deposit init loop", - "04 - deposit", - NB_DEPOSIT_SAVE), + "04 - deposit init loop", + "04 - deposit", + NB_DEPOSIT_SAVE), PERF_TALER_EXCHANGEDB_INIT_CMD_END_LOOP ("04 - deposit init loop end", - "04 - deposit init loop"), + "04 - deposit init loop"), PERF_TALER_EXCHANGEDB_INIT_CMD_GET_TIME ("04 - time stop"), PERF_TALER_EXCHANGEDB_INIT_CMD_GAUGER ("04 - gauger", - "04 - time start", - "04 - time stop", - "TEST", - "time to insert a deposit", - "deposit/sec", - NB_DEPOSIT_SAVE), + "04 - time start", + "04 - time stop", + "TEST", + "time to insert a deposit", + "deposit/sec", + NB_DEPOSIT_SAVE), PERF_TALER_EXCHANGEDB_INIT_CMD_DEBUG ("04 - deposit init complete"), // End of deposit initialization PERF_TALER_EXCHANGEDB_INIT_CMD_END ("end"), diff --git a/src/include/gauger.h b/src/include/gauger.h index 9fa34b9bb..7d66051b7 100644 --- a/src/include/gauger.h +++ b/src/include/gauger.h @@ -17,65 +17,65 @@ #include #include -#define GAUGER(category, counter, value, unit)\ -{\ - const char * __gauger_v[10]; \ - char __gauger_s[32];\ - pid_t __gauger_p;\ - if(!(__gauger_p=fork())){\ - if(!fork()){\ - sprintf(__gauger_s,"%Lf", (long double) (value));\ - __gauger_v[0] = "gauger";\ - __gauger_v[1] = "-n";\ - __gauger_v[2] = (char *) counter; \ - __gauger_v[3] = "-d";\ - __gauger_v[4] = __gauger_s;\ - __gauger_v[5] = "-u";\ - __gauger_v[6] = (char *) unit; \ - __gauger_v[7] = "-c";\ - __gauger_v[8] = (char *) category; \ - __gauger_v[9] = (char *) NULL;\ - execvp("gauger", (char*const*) __gauger_v); \ - perror("gauger");\ - _exit(1);\ - }else{\ - _exit(0);\ - }\ - }else{\ - waitpid(__gauger_p,NULL,0);\ - }\ -} +#define GAUGER(category, counter, value, unit) \ + { \ + const char *__gauger_v[10]; \ + char __gauger_s[32]; \ + pid_t __gauger_p; \ + if (! (__gauger_p = fork ())) { \ + if (! fork ()) { \ + sprintf (__gauger_s,"%Lf", (long double) (value)); \ + __gauger_v[0] = "gauger"; \ + __gauger_v[1] = "-n"; \ + __gauger_v[2] = (char *) counter; \ + __gauger_v[3] = "-d"; \ + __gauger_v[4] = __gauger_s; \ + __gauger_v[5] = "-u"; \ + __gauger_v[6] = (char *) unit; \ + __gauger_v[7] = "-c"; \ + __gauger_v[8] = (char *) category; \ + __gauger_v[9] = (char *) NULL; \ + execvp ("gauger", (char*const*) __gauger_v); \ + perror ("gauger"); \ + _exit (1); \ + }else{ \ + _exit (0); \ + } \ + }else{ \ + waitpid (__gauger_p,NULL,0); \ + } \ + } -#define GAUGER_ID(category, counter, value, unit, id)\ -{\ - char* __gauger_v[12];\ - char __gauger_s[32];\ - pid_t __gauger_p;\ - if(!(__gauger_p=fork())){\ - if(!fork()){\ - sprintf(__gauger_s,"%Lf", (long double) (value));\ - __gauger_v[0] = "gauger";\ - __gauger_v[1] = "-n";\ - __gauger_v[2] = (char *) counter; \ - __gauger_v[3] = "-d";\ - __gauger_v[4] = __gauger_s;\ - __gauger_v[5] = "-u";\ - __gauger_v[6] = (char *) unit; \ - __gauger_v[7] = "-i";\ - __gauger_v[8] = id;\ - __gauger_v[9] = "-c";\ - __gauger_v[10] = (char *) category; \ - __gauger_v[11] = (char *) NULL;\ - execvp("gauger",__gauger_v);\ - perror("gauger");\ - _exit(1);\ - }else{\ - _exit(0);\ - }\ - }else{\ - waitpid(__gauger_p,NULL,0);\ - }\ -} +#define GAUGER_ID(category, counter, value, unit, id) \ + { \ + char*__gauger_v[12]; \ + char __gauger_s[32]; \ + pid_t __gauger_p; \ + if (! (__gauger_p = fork ())) { \ + if (! fork ()) { \ + sprintf (__gauger_s,"%Lf", (long double) (value)); \ + __gauger_v[0] = "gauger"; \ + __gauger_v[1] = "-n"; \ + __gauger_v[2] = (char *) counter; \ + __gauger_v[3] = "-d"; \ + __gauger_v[4] = __gauger_s; \ + __gauger_v[5] = "-u"; \ + __gauger_v[6] = (char *) unit; \ + __gauger_v[7] = "-i"; \ + __gauger_v[8] = id; \ + __gauger_v[9] = "-c"; \ + __gauger_v[10] = (char *) category; \ + __gauger_v[11] = (char *) NULL; \ + execvp ("gauger",__gauger_v); \ + perror ("gauger"); \ + _exit (1); \ + }else{ \ + _exit (0); \ + } \ + }else{ \ + waitpid (__gauger_p,NULL,0); \ + } \ + } #else /* WINDOWS */ @@ -83,25 +83,27 @@ #include #include -#define GAUGER(category, counter, value, unit)\ -{\ - char __gauger_commandline[MAX_PATH];\ +#define GAUGER(category, counter, value, unit) \ + { \ + char __gauger_commandline[MAX_PATH]; \ \ - snprintf (__gauger_commandline, MAX_PATH, "gauger.py -n \"%s\" -d \"%Lf\" -u \"%s\" -c \"%s\"",\ - counter, (long double) (value), unit, category);\ - __gauger_commandline[MAX_PATH - 1] = '\0';\ - system (__gauger_commandline);\ -} + snprintf (__gauger_commandline, MAX_PATH, \ + "gauger.py -n \"%s\" -d \"%Lf\" -u \"%s\" -c \"%s\"", \ + counter, (long double) (value), unit, category); \ + __gauger_commandline[MAX_PATH - 1] = '\0'; \ + system (__gauger_commandline); \ + } -#define GAUGER_ID(category, counter, value, unit, id)\ -{\ - char __gauger_commandline[MAX_PATH];\ +#define GAUGER_ID(category, counter, value, unit, id) \ + { \ + char __gauger_commandline[MAX_PATH]; \ \ - snprintf (__gauger_commandline, MAX_PATH, "gauger.py -n \"%s\" -d \"%Lf\" -u \"%s\" -i \"%s\" -c \"%s\"",\ - counter, (long double) (value), unit, id, category);\ - __gauger_commandline[MAX_PATH - 1] = '\0';\ - system (__gauger_commandline);\ -} + snprintf (__gauger_commandline, MAX_PATH, \ + "gauger.py -n \"%s\" -d \"%Lf\" -u \"%s\" -i \"%s\" -c \"%s\"", \ + counter, (long double) (value), unit, id, category); \ + __gauger_commandline[MAX_PATH - 1] = '\0'; \ + system (__gauger_commandline); \ + } #endif // WINDOWS diff --git a/src/include/platform.h b/src/include/platform.h index 607bd7361..847e024bf 100644 --- a/src/include/platform.h +++ b/src/include/platform.h @@ -18,7 +18,7 @@ * @file include/platform.h * @brief This file contains the includes and definitions which are used by the * rest of the modules - * @author Sree Harsha Totakura + * @author Sree Harsha Totakura */ #ifndef PLATFORM_H_ @@ -36,7 +36,7 @@ #if (GNUNET_EXTRA_LOGGING >= 1) #define VERBOSE(cmd) cmd #else -#define VERBOSE(cmd) do { break; }while(0) +#define VERBOSE(cmd) do { break; } while (0) #endif /* Include the features available for GNU source */ diff --git a/src/include/taler_auditor_service.h b/src/include/taler_auditor_service.h index 5dbbf3d82..012db8ba1 100644 --- a/src/include/taler_auditor_service.h +++ b/src/include/taler_auditor_service.h @@ -83,8 +83,8 @@ enum TALER_AUDITOR_VersionCompatibility * this implementation. */ TALER_AUDITOR_VC_INCOMPATIBLE_OUTDATED - = TALER_AUDITOR_VC_INCOMPATIBLE - | TALER_AUDITOR_VC_OLDER, + = TALER_AUDITOR_VC_INCOMPATIBLE + | TALER_AUDITOR_VC_OLDER, /** * The auditor is more recent than this implementation (bit). @@ -95,8 +95,8 @@ enum TALER_AUDITOR_VersionCompatibility * The auditor is too recent for this implementation. */ TALER_AUDITOR_VC_INCOMPATIBLE_NEWER - = TALER_AUDITOR_VC_INCOMPATIBLE - | TALER_AUDITOR_VC_NEWER, + = TALER_AUDITOR_VC_INCOMPATIBLE + | TALER_AUDITOR_VC_NEWER, /** * We could not even parse the version data. @@ -115,8 +115,10 @@ enum TALER_AUDITOR_VersionCompatibility */ typedef void (*TALER_AUDITOR_VersionCallback) (void *cls, - const struct TALER_AUDITOR_VersionInformation *vi, - enum TALER_AUDITOR_VersionCompatibility compat); + const struct + TALER_AUDITOR_VersionInformation *vi, + enum TALER_AUDITOR_VersionCompatibility + compat); /** @@ -142,9 +144,9 @@ struct TALER_AUDITOR_Handle; */ struct TALER_AUDITOR_Handle * TALER_AUDITOR_connect (struct GNUNET_CURL_Context *ctx, - const char *url, - TALER_AUDITOR_VersionCallback version_cb, - void *version_cb_cls); + const char *url, + TALER_AUDITOR_VersionCallback version_cb, + void *version_cb_cls); /** @@ -214,21 +216,30 @@ typedef void struct TALER_AUDITOR_DepositConfirmationHandle * TALER_AUDITOR_deposit_confirmation (struct TALER_AUDITOR_Handle *auditor, const struct GNUNET_HashCode *h_wire, - const struct GNUNET_HashCode *h_contract_terms, + const struct + GNUNET_HashCode *h_contract_terms, struct GNUNET_TIME_Absolute timestamp, struct GNUNET_TIME_Absolute refund_deadline, - const struct TALER_Amount *amount_without_fee, - const struct TALER_CoinSpendPublicKeyP *coin_pub, - const struct TALER_MerchantPublicKeyP *merchant_pub, - const struct TALER_ExchangePublicKeyP *exchange_pub, - const struct TALER_ExchangeSignatureP *exchange_sig, - const struct TALER_MasterPublicKeyP *master_pub, + const struct + TALER_Amount *amount_without_fee, + const struct + TALER_CoinSpendPublicKeyP *coin_pub, + const struct + TALER_MerchantPublicKeyP *merchant_pub, + const struct + TALER_ExchangePublicKeyP *exchange_pub, + const struct + TALER_ExchangeSignatureP *exchange_sig, + const struct + TALER_MasterPublicKeyP *master_pub, struct GNUNET_TIME_Absolute ep_start, struct GNUNET_TIME_Absolute ep_expire, struct GNUNET_TIME_Absolute ep_legal_end, - const struct TALER_MasterSignatureP *master_sig, - TALER_AUDITOR_DepositConfirmationResultCallback cb, - void *cb_cls); + const struct + TALER_MasterSignatureP *master_sig, + TALER_AUDITOR_DepositConfirmationResultCallback + cb, + void *cb_cls); /** @@ -238,7 +249,9 @@ TALER_AUDITOR_deposit_confirmation (struct TALER_AUDITOR_Handle *auditor, * @param deposit-confirmation the deposit-confirmation permission request handle */ void -TALER_AUDITOR_deposit_confirmation_cancel (struct TALER_AUDITOR_DepositConfirmationHandle *deposit_confirmation); +TALER_AUDITOR_deposit_confirmation_cancel (struct + TALER_AUDITOR_DepositConfirmationHandle + *deposit_confirmation); /** @@ -281,7 +294,8 @@ typedef void unsigned int http_status, enum TALER_ErrorCode ec, unsigned int num_exchanges, - const struct TALER_AUDITOR_ExchangeInfo *ei, + const struct + TALER_AUDITOR_ExchangeInfo *ei, const json_t *raw_response); /** @@ -308,7 +322,8 @@ TALER_AUDITOR_list_exchanges (struct TALER_AUDITOR_Handle *auditor, * @param deposit-confirmation the deposit-confirmation permission request handle */ void -TALER_AUDITOR_list_exchanges_cancel (struct TALER_AUDITOR_ListExchangesHandle *leh); +TALER_AUDITOR_list_exchanges_cancel (struct + TALER_AUDITOR_ListExchangesHandle *leh); #endif /* _TALER_AUDITOR_SERVICE_H */ diff --git a/src/include/taler_auditordb_plugin.h b/src/include/taler_auditordb_plugin.h index 98fce62df..7a972c64a 100644 --- a/src/include/taler_auditordb_plugin.h +++ b/src/include/taler_auditordb_plugin.h @@ -39,7 +39,8 @@ */ typedef void (*TALER_AUDITORDB_ExchangeCallback)(void *cls, - const struct TALER_MasterPublicKeyP *master_pub, + const struct + TALER_MasterPublicKeyP *master_pub, const char *exchange_url); @@ -56,7 +57,9 @@ typedef void */ typedef int (*TALER_AUDITORDB_DenominationInfoDataCallback)(void *cls, - const struct TALER_DenominationKeyValidityPS *issue); + const struct + TALER_DenominationKeyValidityPS + *issue); /** @@ -76,10 +79,18 @@ typedef int */ typedef int (*TALER_AUDITORDB_HistoricDenominationRevenueDataCallback)(void *cls, - const struct GNUNET_HashCode *denom_pub_hash, - struct GNUNET_TIME_Absolute revenue_timestamp, - const struct TALER_Amount *revenue_balance, - const struct TALER_Amount *loss_balance); + const struct + GNUNET_HashCode * + denom_pub_hash, + struct + GNUNET_TIME_Absolute + revenue_timestamp, + const struct + TALER_Amount * + revenue_balance, + const struct + TALER_Amount * + loss_balance); /** @@ -97,9 +108,15 @@ typedef int */ typedef int (*TALER_AUDITORDB_HistoricReserveRevenueDataCallback)(void *cls, - struct GNUNET_TIME_Absolute start_time, - struct GNUNET_TIME_Absolute end_time, - const struct TALER_Amount *reserve_profits); + struct + GNUNET_TIME_Absolute + start_time, + struct + GNUNET_TIME_Absolute + end_time, + const struct + TALER_Amount * + reserve_profits); /** @@ -358,7 +375,9 @@ struct TALER_AUDITORDB_DepositConfirmation typedef void (*TALER_AUDITORDB_DepositConfirmationCallback)(void *cls, uint64_t serial_id, - const struct TALER_AUDITORDB_DepositConfirmation *dc); + const struct + TALER_AUDITORDB_DepositConfirmation + *dc); /** @@ -441,8 +460,8 @@ struct TALER_AUDITORDB_Plugin * @return transaction status code */ enum GNUNET_DB_QueryStatus - (*commit) (void *cls, - struct TALER_AUDITORDB_Session *session); + (*commit)(void *cls, + struct TALER_AUDITORDB_Session *session); /** @@ -478,10 +497,10 @@ struct TALER_AUDITORDB_Plugin * @return query result status */ enum GNUNET_DB_QueryStatus - (*insert_exchange) (void *cls, - struct TALER_AUDITORDB_Session *session, - const struct TALER_MasterPublicKeyP *master_pub, - const char *exchange_url); + (*insert_exchange)(void *cls, + struct TALER_AUDITORDB_Session *session, + const struct TALER_MasterPublicKeyP *master_pub, + const char *exchange_url); /** @@ -495,9 +514,9 @@ struct TALER_AUDITORDB_Plugin * @return query result status */ enum GNUNET_DB_QueryStatus - (*delete_exchange) (void *cls, - struct TALER_AUDITORDB_Session *session, - const struct TALER_MasterPublicKeyP *master_pub); + (*delete_exchange)(void *cls, + struct TALER_AUDITORDB_Session *session, + const struct TALER_MasterPublicKeyP *master_pub); /** @@ -510,10 +529,10 @@ struct TALER_AUDITORDB_Plugin * @return query result status */ enum GNUNET_DB_QueryStatus - (*list_exchanges) (void *cls, - struct TALER_AUDITORDB_Session *session, - TALER_AUDITORDB_ExchangeCallback cb, - void *cb_cls); + (*list_exchanges)(void *cls, + struct TALER_AUDITORDB_Session *session, + TALER_AUDITORDB_ExchangeCallback cb, + void *cb_cls); /** * Insert information about a signing key of the exchange. @@ -524,9 +543,10 @@ struct TALER_AUDITORDB_Plugin * @return query result status */ enum GNUNET_DB_QueryStatus - (*insert_exchange_signkey) (void *cls, - struct TALER_AUDITORDB_Session *session, - const struct TALER_AUDITORDB_ExchangeSigningKey *sk); + (*insert_exchange_signkey)(void *cls, + struct TALER_AUDITORDB_Session *session, + const struct + TALER_AUDITORDB_ExchangeSigningKey *sk); /** @@ -538,9 +558,10 @@ struct TALER_AUDITORDB_Plugin * @return query result status */ enum GNUNET_DB_QueryStatus - (*insert_deposit_confirmation) (void *cls, - struct TALER_AUDITORDB_Session *session, - const struct TALER_AUDITORDB_DepositConfirmation *dc); + (*insert_deposit_confirmation)(void *cls, + struct TALER_AUDITORDB_Session *session, + const struct + TALER_AUDITORDB_DepositConfirmation *dc); /** @@ -556,12 +577,13 @@ struct TALER_AUDITORDB_Plugin * @return query result status */ enum GNUNET_DB_QueryStatus - (*get_deposit_confirmations) (void *cls, - struct TALER_AUDITORDB_Session *session, - const struct TALER_MasterPublicKeyP *master_public_key, - uint64_t start_id, - TALER_AUDITORDB_DepositConfirmationCallback cb, - void *cb_cls); + (*get_deposit_confirmations)(void *cls, + struct TALER_AUDITORDB_Session *session, + const struct + TALER_MasterPublicKeyP *master_public_key, + uint64_t start_id, + TALER_AUDITORDB_DepositConfirmationCallback cb, + void *cb_cls); /** @@ -577,7 +599,8 @@ struct TALER_AUDITORDB_Plugin enum GNUNET_DB_QueryStatus (*insert_denomination_info)(void *cls, struct TALER_AUDITORDB_Session *session, - const struct TALER_DenominationKeyValidityPS *issue); + const struct + TALER_DenominationKeyValidityPS *issue); /** @@ -611,8 +634,10 @@ struct TALER_AUDITORDB_Plugin enum GNUNET_DB_QueryStatus (*insert_auditor_progress_coin)(void *cls, struct TALER_AUDITORDB_Session *session, - const struct TALER_MasterPublicKeyP *master_pub, - const struct TALER_AUDITORDB_ProgressPointCoin *ppc); + const struct + TALER_MasterPublicKeyP *master_pub, + const struct + TALER_AUDITORDB_ProgressPointCoin *ppc); /** @@ -628,8 +653,10 @@ struct TALER_AUDITORDB_Plugin enum GNUNET_DB_QueryStatus (*update_auditor_progress_coin)(void *cls, struct TALER_AUDITORDB_Session *session, - const struct TALER_MasterPublicKeyP *master_pub, - const struct TALER_AUDITORDB_ProgressPointCoin *ppc); + const struct + TALER_MasterPublicKeyP *master_pub, + const struct + TALER_AUDITORDB_ProgressPointCoin *ppc); /** @@ -647,21 +674,23 @@ struct TALER_AUDITORDB_Plugin const struct TALER_MasterPublicKeyP *master_pub, struct TALER_AUDITORDB_ProgressPointCoin *ppc); - /** - * Insert information about the auditor's progress with an exchange's - * data. - * - * @param cls the @e cls of this struct with the plugin-specific state - * @param session connection to use - * @param master_pub master key of the exchange - * @param ppr where is the auditor in processing - * @return transaction status code - */ + /** + * Insert information about the auditor's progress with an exchange's + * data. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param session connection to use + * @param master_pub master key of the exchange + * @param ppr where is the auditor in processing + * @return transaction status code + */ enum GNUNET_DB_QueryStatus (*insert_auditor_progress_reserve)(void *cls, struct TALER_AUDITORDB_Session *session, - const struct TALER_MasterPublicKeyP *master_pub, - const struct TALER_AUDITORDB_ProgressPointReserve *ppr); + const struct + TALER_MasterPublicKeyP *master_pub, + const struct + TALER_AUDITORDB_ProgressPointReserve *ppr); /** @@ -677,8 +706,10 @@ struct TALER_AUDITORDB_Plugin enum GNUNET_DB_QueryStatus (*update_auditor_progress_reserve)(void *cls, struct TALER_AUDITORDB_Session *session, - const struct TALER_MasterPublicKeyP *master_pub, - const struct TALER_AUDITORDB_ProgressPointReserve *ppr); + const struct + TALER_MasterPublicKeyP *master_pub, + const struct + TALER_AUDITORDB_ProgressPointReserve *ppr); /** @@ -693,8 +724,10 @@ struct TALER_AUDITORDB_Plugin enum GNUNET_DB_QueryStatus (*get_auditor_progress_reserve)(void *cls, struct TALER_AUDITORDB_Session *session, - const struct TALER_MasterPublicKeyP *master_pub, - struct TALER_AUDITORDB_ProgressPointReserve *ppr); + const struct + TALER_MasterPublicKeyP *master_pub, + struct TALER_AUDITORDB_ProgressPointReserve * + ppr); /** * Insert information about the auditor's progress with an exchange's @@ -708,9 +741,14 @@ struct TALER_AUDITORDB_Plugin */ enum GNUNET_DB_QueryStatus (*insert_auditor_progress_deposit_confirmation)(void *cls, - struct TALER_AUDITORDB_Session *session, - const struct TALER_MasterPublicKeyP *master_pub, - const struct TALER_AUDITORDB_ProgressPointDepositConfirmation *ppdc); + struct TALER_AUDITORDB_Session + *session, + const struct + TALER_MasterPublicKeyP * + master_pub, + const struct + TALER_AUDITORDB_ProgressPointDepositConfirmation + *ppdc); /** @@ -725,9 +763,14 @@ struct TALER_AUDITORDB_Plugin */ enum GNUNET_DB_QueryStatus (*update_auditor_progress_deposit_confirmation)(void *cls, - struct TALER_AUDITORDB_Session *session, - const struct TALER_MasterPublicKeyP *master_pub, - const struct TALER_AUDITORDB_ProgressPointDepositConfirmation *ppdc); + struct TALER_AUDITORDB_Session + *session, + const struct + TALER_MasterPublicKeyP * + master_pub, + const struct + TALER_AUDITORDB_ProgressPointDepositConfirmation + *ppdc); /** @@ -741,9 +784,14 @@ struct TALER_AUDITORDB_Plugin */ enum GNUNET_DB_QueryStatus (*get_auditor_progress_deposit_confirmation)(void *cls, - struct TALER_AUDITORDB_Session *session, - const struct TALER_MasterPublicKeyP *master_pub, - struct TALER_AUDITORDB_ProgressPointDepositConfirmation *ppdc); + struct TALER_AUDITORDB_Session * + session, + const struct + TALER_MasterPublicKeyP * + master_pub, + struct + TALER_AUDITORDB_ProgressPointDepositConfirmation + *ppdc); /** @@ -759,8 +807,11 @@ struct TALER_AUDITORDB_Plugin enum GNUNET_DB_QueryStatus (*insert_auditor_progress_aggregation)(void *cls, struct TALER_AUDITORDB_Session *session, - const struct TALER_MasterPublicKeyP *master_pub, - const struct TALER_AUDITORDB_ProgressPointAggregation *ppa); + const struct + TALER_MasterPublicKeyP *master_pub, + const struct + TALER_AUDITORDB_ProgressPointAggregation + *ppa); /** @@ -776,8 +827,11 @@ struct TALER_AUDITORDB_Plugin enum GNUNET_DB_QueryStatus (*update_auditor_progress_aggregation)(void *cls, struct TALER_AUDITORDB_Session *session, - const struct TALER_MasterPublicKeyP *master_pub, - const struct TALER_AUDITORDB_ProgressPointAggregation *ppa); + const struct + TALER_MasterPublicKeyP *master_pub, + const struct + TALER_AUDITORDB_ProgressPointAggregation + *ppa); /** @@ -792,8 +846,11 @@ struct TALER_AUDITORDB_Plugin enum GNUNET_DB_QueryStatus (*get_auditor_progress_aggregation)(void *cls, struct TALER_AUDITORDB_Session *session, - const struct TALER_MasterPublicKeyP *master_pub, - struct TALER_AUDITORDB_ProgressPointAggregation *ppa); + const struct + TALER_MasterPublicKeyP *master_pub, + struct + TALER_AUDITORDB_ProgressPointAggregation * + ppa); /** @@ -812,10 +869,14 @@ struct TALER_AUDITORDB_Plugin */ enum GNUNET_DB_QueryStatus (*insert_wire_auditor_account_progress)(void *cls, - struct TALER_AUDITORDB_Session *session, - const struct TALER_MasterPublicKeyP *master_pub, + struct TALER_AUDITORDB_Session * + session, + const struct + TALER_MasterPublicKeyP *master_pub, const char *account_name, - const struct TALER_AUDITORDB_WireAccountProgressPoint *pp, + const struct + TALER_AUDITORDB_WireAccountProgressPoint + *pp, const void *in_wire_off, const void *out_wire_off, size_t wire_off_size); @@ -837,14 +898,18 @@ struct TALER_AUDITORDB_Plugin */ enum GNUNET_DB_QueryStatus (*update_wire_auditor_account_progress)(void *cls, - struct TALER_AUDITORDB_Session *session, - const struct TALER_MasterPublicKeyP *master_pub, + struct TALER_AUDITORDB_Session * + session, + const struct + TALER_MasterPublicKeyP *master_pub, const char *account_name, - const struct TALER_AUDITORDB_WireAccountProgressPoint *pp, + const struct + TALER_AUDITORDB_WireAccountProgressPoint + *pp, const void *in_wire_off, const void *out_wire_off, size_t wire_off_size); - + /** * Get information about the progress of the wire auditor. @@ -862,9 +927,12 @@ struct TALER_AUDITORDB_Plugin enum GNUNET_DB_QueryStatus (*get_wire_auditor_account_progress)(void *cls, struct TALER_AUDITORDB_Session *session, - const struct TALER_MasterPublicKeyP *master_pub, + const struct + TALER_MasterPublicKeyP *master_pub, const char *account_name, - struct TALER_AUDITORDB_WireAccountProgressPoint *pp, + struct + TALER_AUDITORDB_WireAccountProgressPoint + *pp, void **in_wire_off, void **out_wire_off, size_t *wire_off_size); @@ -884,8 +952,10 @@ struct TALER_AUDITORDB_Plugin enum GNUNET_DB_QueryStatus (*insert_wire_auditor_progress)(void *cls, struct TALER_AUDITORDB_Session *session, - const struct TALER_MasterPublicKeyP *master_pub, - const struct TALER_AUDITORDB_WireProgressPoint *pp); + const struct + TALER_MasterPublicKeyP *master_pub, + const struct + TALER_AUDITORDB_WireProgressPoint *pp); /** @@ -902,8 +972,10 @@ struct TALER_AUDITORDB_Plugin enum GNUNET_DB_QueryStatus (*update_wire_auditor_progress)(void *cls, struct TALER_AUDITORDB_Session *session, - const struct TALER_MasterPublicKeyP *master_pub, - const struct TALER_AUDITORDB_WireProgressPoint *pp); + const struct + TALER_MasterPublicKeyP *master_pub, + const struct + TALER_AUDITORDB_WireProgressPoint *pp); /** @@ -1301,11 +1373,14 @@ struct TALER_AUDITORDB_Plugin enum GNUNET_DB_QueryStatus (*insert_historic_denom_revenue)(void *cls, struct TALER_AUDITORDB_Session *session, - const struct TALER_MasterPublicKeyP *master_pub, + const struct + TALER_MasterPublicKeyP *master_pub, const struct GNUNET_HashCode *denom_pub_hash, - struct GNUNET_TIME_Absolute revenue_timestamp, + struct GNUNET_TIME_Absolute + revenue_timestamp, const struct TALER_Amount *revenue_balance, - const struct TALER_Amount *payback_loss_balance); + const struct + TALER_Amount *payback_loss_balance); /** @@ -1322,8 +1397,10 @@ struct TALER_AUDITORDB_Plugin enum GNUNET_DB_QueryStatus (*select_historic_denom_revenue)(void *cls, struct TALER_AUDITORDB_Session *session, - const struct TALER_MasterPublicKeyP *master_pub, - TALER_AUDITORDB_HistoricDenominationRevenueDataCallback cb, + const struct + TALER_MasterPublicKeyP *master_pub, + TALER_AUDITORDB_HistoricDenominationRevenueDataCallback + cb, void *cb_cls); @@ -1341,10 +1418,12 @@ struct TALER_AUDITORDB_Plugin enum GNUNET_DB_QueryStatus (*insert_historic_reserve_revenue)(void *cls, struct TALER_AUDITORDB_Session *session, - const struct TALER_MasterPublicKeyP *master_pub, + const struct + TALER_MasterPublicKeyP *master_pub, struct GNUNET_TIME_Absolute start_time, struct GNUNET_TIME_Absolute end_time, - const struct TALER_Amount *reserve_profits); + const struct + TALER_Amount *reserve_profits); /** @@ -1360,8 +1439,10 @@ struct TALER_AUDITORDB_Plugin enum GNUNET_DB_QueryStatus (*select_historic_reserve_revenue)(void *cls, struct TALER_AUDITORDB_Session *session, - const struct TALER_MasterPublicKeyP *master_pub, - TALER_AUDITORDB_HistoricReserveRevenueDataCallback cb, + const struct + TALER_MasterPublicKeyP *master_pub, + TALER_AUDITORDB_HistoricReserveRevenueDataCallback + cb, void *cb_cls); diff --git a/src/include/taler_bank_service.h b/src/include/taler_bank_service.h index 2cebbe6e7..b2a02f74d 100644 --- a/src/include/taler_bank_service.h +++ b/src/include/taler_bank_service.h @@ -31,7 +31,8 @@ /** * Authentication method types. */ -enum TALER_BANK_AuthenticationMethod { +enum TALER_BANK_AuthenticationMethod +{ /** * No authentication. @@ -109,7 +110,8 @@ typedef void unsigned int http_status, enum TALER_ErrorCode ec, uint64_t serial_id, - struct GNUNET_TIME_Absolute timestamp, + struct GNUNET_TIME_Absolute + timestamp, const json_t *json); @@ -153,13 +155,15 @@ TALER_BANK_admin_add_incoming (struct GNUNET_CURL_Context *ctx, * @param aai the admin add incoming request handle */ void -TALER_BANK_admin_add_incoming_cancel (struct TALER_BANK_AdminAddIncomingHandle *aai); +TALER_BANK_admin_add_incoming_cancel (struct + TALER_BANK_AdminAddIncomingHandle *aai); /** * Which types of transactions should be (or is being) returned? */ -enum TALER_BANK_Direction { +enum TALER_BANK_Direction +{ /** * Base case, used to indicate errors or end of list. @@ -179,7 +183,8 @@ enum TALER_BANK_Direction { /** * Return both types of transactions. */ - TALER_BANK_DIRECTION_BOTH = (TALER_BANK_DIRECTION_CREDIT | TALER_BANK_DIRECTION_DEBIT), + TALER_BANK_DIRECTION_BOTH = (TALER_BANK_DIRECTION_CREDIT + | TALER_BANK_DIRECTION_DEBIT), /** * Bit mask that is applied to view transactions that have been @@ -247,7 +252,8 @@ typedef void enum TALER_ErrorCode ec, enum TALER_BANK_Direction dir, uint64_t serial_id, - const struct TALER_BANK_TransferDetails *details, + const struct + TALER_BANK_TransferDetails *details, const json_t *json); diff --git a/src/include/taler_crypto_lib.h b/src/include/taler_crypto_lib.h index 7b9d932d5..5eb4fbf45 100644 --- a/src/include/taler_crypto_lib.h +++ b/src/include/taler_crypto_lib.h @@ -639,8 +639,10 @@ TALER_planchet_to_coin (const struct TALER_DenominationPublicKey *dk, * @param[out] ts computed transfer secret */ void -TALER_link_derive_transfer_secret (const struct TALER_CoinSpendPrivateKeyP *coin_priv, - const struct TALER_TransferPrivateKeyP *trans_priv, +TALER_link_derive_transfer_secret (const struct + TALER_CoinSpendPrivateKeyP *coin_priv, + const struct + TALER_TransferPrivateKeyP *trans_priv, struct TALER_TransferSecretP *ts); @@ -653,8 +655,10 @@ TALER_link_derive_transfer_secret (const struct TALER_CoinSpendPrivateKeyP *coin * @param[out] transfer_secret set to the shared secret */ void -TALER_link_reveal_transfer_secret (const struct TALER_TransferPrivateKeyP *trans_priv, - const struct TALER_CoinSpendPublicKeyP *coin_pub, +TALER_link_reveal_transfer_secret (const struct + TALER_TransferPrivateKeyP *trans_priv, + const struct + TALER_CoinSpendPublicKeyP *coin_pub, struct TALER_TransferSecretP *transfer_secret); @@ -667,9 +671,12 @@ TALER_link_reveal_transfer_secret (const struct TALER_TransferPrivateKeyP *trans * @param[out] transfer_secret set to the shared secret */ void -TALER_link_recover_transfer_secret (const struct TALER_TransferPublicKeyP *trans_pub, - const struct TALER_CoinSpendPrivateKeyP *coin_priv, - struct TALER_TransferSecretP *transfer_secret); +TALER_link_recover_transfer_secret (const struct + TALER_TransferPublicKeyP *trans_pub, + const struct + TALER_CoinSpendPrivateKeyP *coin_priv, + struct TALER_TransferSecretP * + transfer_secret); /** @@ -758,8 +765,10 @@ TALER_exchange_wire_signature_hash (const char *payto_url, */ int TALER_exchange_wire_signature_check (const char *payto_url, - const struct TALER_MasterPublicKeyP *master_pub, - const struct TALER_MasterSignatureP *master_sig); + const struct + TALER_MasterPublicKeyP *master_pub, + const struct + TALER_MasterSignatureP *master_sig); /** @@ -771,7 +780,8 @@ TALER_exchange_wire_signature_check (const char *payto_url, */ void TALER_exchange_wire_signature_make (const char *payto_url, - const struct TALER_MasterPrivateKeyP *master_priv, + const struct + TALER_MasterPrivateKeyP *master_priv, struct TALER_MasterSignatureP *master_sig); @@ -801,8 +811,10 @@ TALER_merchant_wire_signature_hash (const char *payto_url, int TALER_merchant_wire_signature_check (const char *payto_url, const char *salt, - const struct TALER_MerchantPublicKeyP *merch_pub, - const struct TALER_MerchantSignatureP *merch_sig); + const struct + TALER_MerchantPublicKeyP *merch_pub, + const struct + TALER_MerchantSignatureP *merch_sig); /** @@ -816,7 +828,8 @@ TALER_merchant_wire_signature_check (const char *payto_url, void TALER_merchant_wire_signature_make (const char *payto_url, const char *salt, - const struct TALER_MerchantPrivateKeyP *merch_priv, + const struct + TALER_MerchantPrivateKeyP *merch_priv, struct TALER_MerchantSignatureP *merch_sig); diff --git a/src/include/taler_curl_lib.h b/src/include/taler_curl_lib.h index 2d69768cc..6629704fb 100644 --- a/src/include/taler_curl_lib.h +++ b/src/include/taler_curl_lib.h @@ -61,8 +61,8 @@ struct TEAH_PostContext */ int TALER_curl_easy_post (struct TEAH_PostContext *ctx, - CURL *eh, - const json_t *body); + CURL *eh, + const json_t *body); /** diff --git a/src/include/taler_error_codes.h b/src/include/taler_error_codes.h index cd99a40fc..022b22713 100644 --- a/src/include/taler_error_codes.h +++ b/src/include/taler_error_codes.h @@ -111,11 +111,11 @@ enum TALER_ErrorCode */ TALER_EC_DB_COMMIT_FAILED_ON_RETRY = 1004, - /** - * The exchange had insufficient memory to parse the request. This - * response is provided with HTTP status code - * MHD_HTTP_INTERNAL_SERVER_ERROR. - */ + /** + * The exchange had insufficient memory to parse the request. This + * response is provided with HTTP status code + * MHD_HTTP_INTERNAL_SERVER_ERROR. + */ TALER_EC_PARSER_OUT_OF_MEMORY = 1005, /** @@ -1400,7 +1400,7 @@ enum TALER_ErrorCode * storing of coins or other related db operations, like starting/committing * the db transaction or marking a contract as paid. */ - TALER_EC_PAY_DB_STORE_PAYMENTS_ERROR = 2605, + TALER_EC_PAY_DB_STORE_PAYMENTS_ERROR = 2605, /** * The backend failed to sign the refund request. diff --git a/src/include/taler_exchange_service.h b/src/include/taler_exchange_service.h index 864beae74..991e36f12 100644 --- a/src/include/taler_exchange_service.h +++ b/src/include/taler_exchange_service.h @@ -322,8 +322,8 @@ enum TALER_EXCHANGE_VersionCompatibility * this implementation. */ TALER_EXCHANGE_VC_INCOMPATIBLE_OUTDATED - = TALER_EXCHANGE_VC_INCOMPATIBLE - | TALER_EXCHANGE_VC_OLDER, + = TALER_EXCHANGE_VC_INCOMPATIBLE + | TALER_EXCHANGE_VC_OLDER, /** * The exchange is more recent than this implementation (bit). @@ -334,8 +334,8 @@ enum TALER_EXCHANGE_VersionCompatibility * The exchange is too recent for this implementation. */ TALER_EXCHANGE_VC_INCOMPATIBLE_NEWER - = TALER_EXCHANGE_VC_INCOMPATIBLE - | TALER_EXCHANGE_VC_NEWER, + = TALER_EXCHANGE_VC_INCOMPATIBLE + | TALER_EXCHANGE_VC_NEWER, /** * We could not even parse the version data. @@ -357,7 +357,9 @@ enum TALER_EXCHANGE_VersionCompatibility typedef void (*TALER_EXCHANGE_CertificationCallback) (void *cls, const struct TALER_EXCHANGE_Keys *keys, - enum TALER_EXCHANGE_VersionCompatibility compat); + enum + TALER_EXCHANGE_VersionCompatibility + compat); /** @@ -500,7 +502,8 @@ TALER_EXCHANGE_test_signing_key (const struct TALER_EXCHANGE_Keys *keys, */ const struct TALER_EXCHANGE_SigningPublicKey * TALER_EXCHANGE_get_signing_key_details (const struct TALER_EXCHANGE_Keys *keys, - const struct TALER_ExchangePublicKeyP *pub); + const struct + TALER_ExchangePublicKeyP *pub); /** @@ -523,7 +526,8 @@ TALER_EXCHANGE_get_base_url (const struct TALER_EXCHANGE_Handle *exchange); */ const struct TALER_EXCHANGE_DenomPublicKey * TALER_EXCHANGE_get_denomination_key (const struct TALER_EXCHANGE_Keys *keys, - const struct TALER_DenominationPublicKey *pk); + const struct + TALER_DenominationPublicKey *pk); /** @@ -534,7 +538,8 @@ TALER_EXCHANGE_get_denomination_key (const struct TALER_EXCHANGE_Keys *keys, * @return details about the given denomination key */ const struct TALER_EXCHANGE_DenomPublicKey * -TALER_EXCHANGE_get_denomination_key_by_hash (const struct TALER_EXCHANGE_Keys *keys, +TALER_EXCHANGE_get_denomination_key_by_hash (const struct + TALER_EXCHANGE_Keys *keys, const struct GNUNET_HashCode *hc); @@ -547,8 +552,11 @@ TALER_EXCHANGE_get_denomination_key_by_hash (const struct TALER_EXCHANGE_Keys *k * @return NULL on error (@a exchange_pub not known) */ const struct TALER_EXCHANGE_SigningPublicKey * -TALER_EXCHANGE_get_exchange_signing_key_info (const struct TALER_EXCHANGE_Keys *keys, - const struct TALER_ExchangePublicKeyP *exchange_pub); +TALER_EXCHANGE_get_exchange_signing_key_info (const struct + TALER_EXCHANGE_Keys *keys, + const struct + TALER_ExchangePublicKeyP * + exchange_pub); /* ********************* /wire *********************** */ @@ -633,9 +641,10 @@ struct TALER_EXCHANGE_WireAccount typedef void (*TALER_EXCHANGE_WireResultCallback) (void *cls, unsigned int http_status, - enum TALER_ErrorCode ec, + enum TALER_ErrorCode ec, unsigned int accounts_len, - const struct TALER_EXCHANGE_WireAccount *accounts); + const struct + TALER_EXCHANGE_WireAccount *accounts); /** @@ -703,9 +712,11 @@ struct TALER_EXCHANGE_DepositHandle; typedef void (*TALER_EXCHANGE_DepositResultCallback) (void *cls, unsigned int http_status, - enum TALER_ErrorCode ec, - const struct TALER_ExchangeSignatureP *exchange_sig, - const struct TALER_ExchangePublicKeyP *sign_key, + enum TALER_ErrorCode ec, + const struct + TALER_ExchangeSignatureP *exchange_sig, + const struct + TALER_ExchangePublicKeyP *sign_key, const json_t *obj); @@ -791,10 +802,11 @@ struct TALER_EXCHANGE_RefundHandle; */ typedef void (*TALER_EXCHANGE_RefundResultCallback) (void *cls, - unsigned int http_status, - enum TALER_ErrorCode ec, - const struct TALER_ExchangePublicKeyP *sign_key, - const json_t *obj); + unsigned int http_status, + enum TALER_ErrorCode ec, + const struct + TALER_ExchangePublicKeyP *sign_key, + const json_t *obj); /** @@ -829,14 +841,14 @@ typedef void */ struct TALER_EXCHANGE_RefundHandle * TALER_EXCHANGE_refund (struct TALER_EXCHANGE_Handle *exchange, - const struct TALER_Amount *amount, - const struct TALER_Amount *refund_fee, - const struct GNUNET_HashCode *h_contract_terms, - const struct TALER_CoinSpendPublicKeyP *coin_pub, - uint64_t rtransaction_id, - const struct TALER_MerchantPrivateKeyP *merchant_priv, - TALER_EXCHANGE_RefundResultCallback cb, - void *cb_cls); + const struct TALER_Amount *amount, + const struct TALER_Amount *refund_fee, + const struct GNUNET_HashCode *h_contract_terms, + const struct TALER_CoinSpendPublicKeyP *coin_pub, + uint64_t rtransaction_id, + const struct TALER_MerchantPrivateKeyP *merchant_priv, + TALER_EXCHANGE_RefundResultCallback cb, + void *cb_cls); /** @@ -872,15 +884,15 @@ TALER_EXCHANGE_refund (struct TALER_EXCHANGE_Handle *exchange, */ struct TALER_EXCHANGE_RefundHandle * TALER_EXCHANGE_refund2 (struct TALER_EXCHANGE_Handle *exchange, - const struct TALER_Amount *amount, - const struct TALER_Amount *refund_fee, - const struct GNUNET_HashCode *h_contract_terms, - const struct TALER_CoinSpendPublicKeyP *coin_pub, - uint64_t rtransaction_id, - const struct TALER_MerchantPublicKeyP *merchant_pub, - const struct TALER_MerchantSignatureP *merchant_sig, - TALER_EXCHANGE_RefundResultCallback cb, - void *cb_cls); + const struct TALER_Amount *amount, + const struct TALER_Amount *refund_fee, + const struct GNUNET_HashCode *h_contract_terms, + const struct TALER_CoinSpendPublicKeyP *coin_pub, + uint64_t rtransaction_id, + const struct TALER_MerchantPublicKeyP *merchant_pub, + const struct TALER_MerchantSignatureP *merchant_sig, + TALER_EXCHANGE_RefundResultCallback cb, + void *cb_cls); /** @@ -907,7 +919,8 @@ struct TALER_EXCHANGE_ReserveStatusHandle; /** * Ways how a reserve's balance may change. */ -enum TALER_EXCHANGE_ReserveTransactionType { +enum TALER_EXCHANGE_ReserveTransactionType +{ /** * Deposit into the reserve. @@ -951,13 +964,15 @@ struct TALER_EXCHANGE_ReserveHistory /** * Details depending on @e type. */ - union { + union + { /** * Information about a deposit that filled this reserve. * @e type is #TALER_EXCHANGE_RTT_DEPOSIT. */ - struct { + struct + { /** * Sender account payto://-URL of the incoming transfer. */ @@ -990,7 +1005,8 @@ struct TALER_EXCHANGE_ReserveHistory * Information provided if the reserve was filled via /payback. * @e type is #TALER_EXCHANGE_RTT_PAYBACK. */ - struct { + struct + { /** * Public key of the coin that was paid back. @@ -1019,7 +1035,8 @@ struct TALER_EXCHANGE_ReserveHistory * Information about a close operation of the reserve. * @e type is #TALER_EXCHANGE_RTT_CLOSE. */ - struct { + struct + { /** * Receiver account information for the outgoing wire transfer. */ @@ -1069,11 +1086,14 @@ struct TALER_EXCHANGE_ReserveHistory typedef void (*TALER_EXCHANGE_ReserveStatusResultCallback) (void *cls, unsigned int http_status, - enum TALER_ErrorCode ec, + enum TALER_ErrorCode ec, const json_t *json, - const struct TALER_Amount *balance, + const struct + TALER_Amount *balance, unsigned int history_length, - const struct TALER_EXCHANGE_ReserveHistory *history); + const struct + TALER_EXCHANGE_ReserveHistory * + history); /** @@ -1094,7 +1114,8 @@ typedef void */ struct TALER_EXCHANGE_ReserveStatusHandle * TALER_EXCHANGE_reserve_status (struct TALER_EXCHANGE_Handle *exchange, - const struct TALER_ReservePublicKeyP *reserve_pub, + const struct + TALER_ReservePublicKeyP *reserve_pub, TALER_EXCHANGE_ReserveStatusResultCallback cb, void *cb_cls); @@ -1106,7 +1127,8 @@ TALER_EXCHANGE_reserve_status (struct TALER_EXCHANGE_Handle *exchange, * @param rsh the reserve status request handle */ void -TALER_EXCHANGE_reserve_status_cancel (struct TALER_EXCHANGE_ReserveStatusHandle *rsh); +TALER_EXCHANGE_reserve_status_cancel (struct + TALER_EXCHANGE_ReserveStatusHandle *rsh); /* ********************* /reserve/withdraw *********************** */ @@ -1133,7 +1155,9 @@ typedef void (*TALER_EXCHANGE_ReserveWithdrawResultCallback) (void *cls, unsigned int http_status, enum TALER_ErrorCode ec, - const struct TALER_DenominationSignature *sig, + const struct + TALER_DenominationSignature * + sig, const json_t *full_response); @@ -1161,9 +1185,11 @@ typedef void struct TALER_EXCHANGE_ReserveWithdrawHandle * TALER_EXCHANGE_reserve_withdraw (struct TALER_EXCHANGE_Handle *exchange, const struct TALER_EXCHANGE_DenomPublicKey *pk, - const struct TALER_ReservePrivateKeyP *reserve_priv, + const struct + TALER_ReservePrivateKeyP *reserve_priv, const struct TALER_PlanchetSecretsP *ps, - TALER_EXCHANGE_ReserveWithdrawResultCallback res_cb, + TALER_EXCHANGE_ReserveWithdrawResultCallback + res_cb, void *res_cb_cls); @@ -1191,11 +1217,15 @@ TALER_EXCHANGE_reserve_withdraw (struct TALER_EXCHANGE_Handle *exchange, */ struct TALER_EXCHANGE_ReserveWithdrawHandle * TALER_EXCHANGE_reserve_withdraw2 (struct TALER_EXCHANGE_Handle *exchange, - const struct TALER_EXCHANGE_DenomPublicKey *pk, - const struct TALER_ReserveSignatureP *reserve_sig, - const struct TALER_ReservePublicKeyP *reserve_pub, + const struct + TALER_EXCHANGE_DenomPublicKey *pk, + const struct + TALER_ReserveSignatureP *reserve_sig, + const struct + TALER_ReservePublicKeyP *reserve_pub, const struct TALER_PlanchetSecretsP *ps, - TALER_EXCHANGE_ReserveWithdrawResultCallback res_cb, + TALER_EXCHANGE_ReserveWithdrawResultCallback + res_cb, void *res_cb_cls); @@ -1206,7 +1236,9 @@ TALER_EXCHANGE_reserve_withdraw2 (struct TALER_EXCHANGE_Handle *exchange, * @param sign the withdraw sign request handle */ void -TALER_EXCHANGE_reserve_withdraw_cancel (struct TALER_EXCHANGE_ReserveWithdrawHandle *sign); +TALER_EXCHANGE_reserve_withdraw_cancel (struct + TALER_EXCHANGE_ReserveWithdrawHandle * + sign); /* ********************* /refresh/melt+reveal ***************************** */ @@ -1254,13 +1286,17 @@ TALER_EXCHANGE_reserve_withdraw_cancel (struct TALER_EXCHANGE_ReserveWithdrawHan * Non-null results should be freed using GNUNET_free(). */ char * -TALER_EXCHANGE_refresh_prepare (const struct TALER_CoinSpendPrivateKeyP *melt_priv, +TALER_EXCHANGE_refresh_prepare (const struct + TALER_CoinSpendPrivateKeyP *melt_priv, const struct TALER_Amount *melt_amount, - const struct TALER_DenominationSignature *melt_sig, - const struct TALER_EXCHANGE_DenomPublicKey *melt_pk, + const struct + TALER_DenominationSignature *melt_sig, + const struct + TALER_EXCHANGE_DenomPublicKey *melt_pk, int check_sig, unsigned int fresh_pks_len, - const struct TALER_EXCHANGE_DenomPublicKey *fresh_pks, + const struct + TALER_EXCHANGE_DenomPublicKey *fresh_pks, size_t *res_size); @@ -1291,7 +1327,8 @@ typedef void unsigned int http_status, enum TALER_ErrorCode ec, uint32_t noreveal_index, - const struct TALER_ExchangePublicKeyP *sign_key, + const struct + TALER_ExchangePublicKeyP *sign_key, const json_t *full_response); @@ -1330,7 +1367,8 @@ TALER_EXCHANGE_refresh_melt (struct TALER_EXCHANGE_Handle *exchange, * @param rmh the refresh handle */ void -TALER_EXCHANGE_refresh_melt_cancel (struct TALER_EXCHANGE_RefreshMeltHandle *rmh); +TALER_EXCHANGE_refresh_melt_cancel (struct + TALER_EXCHANGE_RefreshMeltHandle *rmh); /* ********************* /refresh/reveal ***************************** */ @@ -1358,8 +1396,10 @@ typedef void unsigned int http_status, enum TALER_ErrorCode ec, unsigned int num_coins, - const struct TALER_PlanchetSecretsP *coin_privs, - const struct TALER_DenominationSignature *sigs, + const struct + TALER_PlanchetSecretsP *coin_privs, + const struct + TALER_DenominationSignature *sigs, const json_t *full_response); @@ -1407,7 +1447,8 @@ TALER_EXCHANGE_refresh_reveal (struct TALER_EXCHANGE_Handle *exchange, * @param rrh the refresh reval handle */ void -TALER_EXCHANGE_refresh_reveal_cancel (struct TALER_EXCHANGE_RefreshRevealHandle *rrh); +TALER_EXCHANGE_refresh_reveal_cancel (struct + TALER_EXCHANGE_RefreshRevealHandle *rrh); /* ********************* /refresh/link ***************************** */ @@ -1438,11 +1479,14 @@ struct TALER_EXCHANGE_RefreshLinkHandle; typedef void (*TALER_EXCHANGE_RefreshLinkCallback) (void *cls, unsigned int http_status, - enum TALER_ErrorCode ec, + enum TALER_ErrorCode ec, unsigned int num_coins, - const struct TALER_CoinSpendPrivateKeyP *coin_privs, - const struct TALER_DenominationSignature *sigs, - const struct TALER_DenominationPublicKey *pubs, + const struct + TALER_CoinSpendPrivateKeyP *coin_privs, + const struct + TALER_DenominationSignature *sigs, + const struct + TALER_DenominationPublicKey *pubs, const json_t *full_response); @@ -1475,7 +1519,8 @@ TALER_EXCHANGE_refresh_link (struct TALER_EXCHANGE_Handle *exchange, * @param rlh the refresh link handle */ void -TALER_EXCHANGE_refresh_link_cancel (struct TALER_EXCHANGE_RefreshLinkHandle *rlh); +TALER_EXCHANGE_refresh_link_cancel (struct + TALER_EXCHANGE_RefreshLinkHandle *rlh); /* ********************* /track/transfer *********************** */ @@ -1507,15 +1552,18 @@ struct TALER_EXCHANGE_TrackTransferHandle; typedef void (*TALER_EXCHANGE_TrackTransferCallback)(void *cls, unsigned int http_status, - enum TALER_ErrorCode ec, - const struct TALER_ExchangePublicKeyP *sign_key, + enum TALER_ErrorCode ec, + const struct + TALER_ExchangePublicKeyP *sign_key, const json_t *json, const struct GNUNET_HashCode *h_wire, - struct GNUNET_TIME_Absolute execution_time, + struct GNUNET_TIME_Absolute + execution_time, const struct TALER_Amount *total_amount, const struct TALER_Amount *wire_fee, unsigned int details_length, - const struct TALER_TrackTransferDetails *details); + const struct + TALER_TrackTransferDetails *details); /** @@ -1530,7 +1578,8 @@ typedef void */ struct TALER_EXCHANGE_TrackTransferHandle * TALER_EXCHANGE_track_transfer (struct TALER_EXCHANGE_Handle *exchange, - const struct TALER_WireTransferIdentifierRawP *wtid, + const struct + TALER_WireTransferIdentifierRawP *wtid, TALER_EXCHANGE_TrackTransferCallback cb, void *cb_cls); @@ -1542,7 +1591,8 @@ TALER_EXCHANGE_track_transfer (struct TALER_EXCHANGE_Handle *exchange, * @param wdh the wire deposits request handle */ void -TALER_EXCHANGE_track_transfer_cancel (struct TALER_EXCHANGE_TrackTransferHandle *wdh); +TALER_EXCHANGE_track_transfer_cancel (struct + TALER_EXCHANGE_TrackTransferHandle *wdh); /* ********************* /track/transaction *********************** */ @@ -1571,12 +1621,17 @@ struct TALER_EXCHANGE_TrackTransactionHandle; typedef void (*TALER_EXCHANGE_TrackTransactionCallback)(void *cls, unsigned int http_status, - enum TALER_ErrorCode ec, - const struct TALER_ExchangePublicKeyP *sign_key, + enum TALER_ErrorCode ec, + const struct + TALER_ExchangePublicKeyP *sign_key, const json_t *json, - const struct TALER_WireTransferIdentifierRawP *wtid, - struct GNUNET_TIME_Absolute execution_time, - const struct TALER_Amount *coin_contribution); + const struct + TALER_WireTransferIdentifierRawP * + wtid, + struct GNUNET_TIME_Absolute + execution_time, + const struct + TALER_Amount *coin_contribution); /** @@ -1593,10 +1648,13 @@ typedef void */ struct TALER_EXCHANGE_TrackTransactionHandle * TALER_EXCHANGE_track_transaction (struct TALER_EXCHANGE_Handle *exchange, - const struct TALER_MerchantPrivateKeyP *merchant_priv, + const struct + TALER_MerchantPrivateKeyP *merchant_priv, const struct GNUNET_HashCode *h_wire, - const struct GNUNET_HashCode *h_contract_terms, - const struct TALER_CoinSpendPublicKeyP *coin_pub, + const struct + GNUNET_HashCode *h_contract_terms, + const struct + TALER_CoinSpendPublicKeyP *coin_pub, TALER_EXCHANGE_TrackTransactionCallback cb, void *cb_cls); @@ -1608,7 +1666,9 @@ TALER_EXCHANGE_track_transaction (struct TALER_EXCHANGE_Handle *exchange, * @param dwh the wire deposits request handle */ void -TALER_EXCHANGE_track_transaction_cancel (struct TALER_EXCHANGE_TrackTransactionHandle *dwh); +TALER_EXCHANGE_track_transaction_cancel (struct + TALER_EXCHANGE_TrackTransactionHandle * + dwh); @@ -1624,7 +1684,8 @@ TALER_EXCHANGE_track_transaction_cancel (struct TALER_EXCHANGE_TrackTransactionH */ int TALER_EXCHANGE_verify_coin_history (const char *currency, - const struct TALER_CoinSpendPublicKeyP *coin_pub, + const struct + TALER_CoinSpendPublicKeyP *coin_pub, json_t *history, struct TALER_Amount *total); @@ -1663,8 +1724,10 @@ typedef void enum TALER_ErrorCode ec, const struct TALER_Amount *amount, struct GNUNET_TIME_Absolute timestamp, - const struct TALER_ReservePublicKeyP *reserve_pub, - const struct TALER_CoinSpendPublicKeyP *old_coin_pub, + const struct + TALER_ReservePublicKeyP *reserve_pub, + const struct + TALER_CoinSpendPublicKeyP *old_coin_pub, const json_t *full_response); diff --git a/src/include/taler_exchangedb_lib.h b/src/include/taler_exchangedb_lib.h index da744506c..e63640628 100644 --- a/src/include/taler_exchangedb_lib.h +++ b/src/include/taler_exchangedb_lib.h @@ -128,7 +128,9 @@ struct TALER_EXCHANGEDB_DenominationKeyIssueInformation typedef int (*TALER_EXCHANGEDB_SigningKeyIterator)(void *cls, const char *filename, - const struct TALER_EXCHANGEDB_PrivateSigningKeyInformationP *ski); + const struct + TALER_EXCHANGEDB_PrivateSigningKeyInformationP + *ski); /** @@ -160,7 +162,9 @@ TALER_EXCHANGEDB_signing_keys_iterate (const char *exchange_base_dir, int TALER_EXCHANGEDB_signing_key_write (const char *exchange_base_dir, struct GNUNET_TIME_Absolute start, - const struct TALER_EXCHANGEDB_PrivateSigningKeyInformationP *ski); + const struct + TALER_EXCHANGEDB_PrivateSigningKeyInformationP + *ski); /** @@ -176,7 +180,9 @@ TALER_EXCHANGEDB_signing_key_write (const char *exchange_base_dir, typedef int (*TALER_EXCHANGEDB_DenominationKeyIterator)(void *cls, const char *alias, - const struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *dki); + const struct + TALER_EXCHANGEDB_DenominationKeyIssueInformation + *dki); /** @@ -192,7 +198,9 @@ typedef int typedef int (*TALER_EXCHANGEDB_RevocationIterator)(void *cls, const struct GNUNET_HashCode *denom_hash, - const struct TALER_MasterSignatureP *revocation_master_sig); + const struct + TALER_MasterSignatureP * + revocation_master_sig); /** @@ -210,7 +218,8 @@ typedef int */ int TALER_EXCHANGEDB_denomination_keys_iterate (const char *exchange_base_dir, - TALER_EXCHANGEDB_DenominationKeyIterator it, + TALER_EXCHANGEDB_DenominationKeyIterator + it, void *it_cls); @@ -228,9 +237,10 @@ TALER_EXCHANGEDB_denomination_keys_iterate (const char *exchange_base_dir, */ int TALER_EXCHANGEDB_revocations_iterate (const char *revocation_dir, - const struct TALER_MasterPublicKeyP *master_pub, - TALER_EXCHANGEDB_RevocationIterator it, - void *it_cls); + const struct + TALER_MasterPublicKeyP *master_pub, + TALER_EXCHANGEDB_RevocationIterator it, + void *it_cls); /** @@ -244,8 +254,10 @@ TALER_EXCHANGEDB_revocations_iterate (const char *revocation_dir, */ int TALER_EXCHANGEDB_denomination_key_revoke (const char *revocation_dir, - const struct GNUNET_HashCode *denom_hash, - const struct TALER_MasterPrivateKeyP *mpriv); + const struct + GNUNET_HashCode *denom_hash, + const struct + TALER_MasterPrivateKeyP *mpriv); /** @@ -257,7 +269,9 @@ TALER_EXCHANGEDB_denomination_key_revoke (const char *revocation_dir, */ int TALER_EXCHANGEDB_denomination_key_write (const char *filename, - const struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *dki); + const struct + TALER_EXCHANGEDB_DenominationKeyIssueInformation + *dki); /** @@ -269,7 +283,9 @@ TALER_EXCHANGEDB_denomination_key_write (const char *filename, */ int TALER_EXCHANGEDB_denomination_key_read (const char *filename, - struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *dki); + struct + TALER_EXCHANGEDB_DenominationKeyIssueInformation + *dki); /** @@ -293,7 +309,8 @@ typedef int const struct TALER_MasterPublicKeyP *mpub, unsigned int dki_len, const struct TALER_AuditorSignatureP *asigs, - const struct TALER_DenominationKeyValidityPS *dki); + const struct + TALER_DenominationKeyValidityPS *dki); /** @@ -333,7 +350,8 @@ TALER_EXCHANGEDB_auditor_write (const char *filename, const struct TALER_AuditorSignatureP *asigs, const struct TALER_MasterPublicKeyP *mpub, unsigned int dki_len, - const struct TALER_DenominationKeyValidityPS *dki); + const struct + TALER_DenominationKeyValidityPS *dki); /** @@ -492,7 +510,8 @@ struct TALER_EXCHANGEDB_AccountInfo */ typedef void (*TALER_EXCHANGEDB_AccountCallback)(void *cls, - const struct TALER_EXCHANGEDB_AccountInfo *ai); + const struct + TALER_EXCHANGEDB_AccountInfo *ai); /** * Parse the configuration to find account information. diff --git a/src/include/taler_exchangedb_plugin.h b/src/include/taler_exchangedb_plugin.h index 61ec53054..88cb2a402 100644 --- a/src/include/taler_exchangedb_plugin.h +++ b/src/include/taler_exchangedb_plugin.h @@ -602,7 +602,8 @@ struct TALER_EXCHANGEDB_LinkDataList * @brief Enumeration to classify the different types of transactions * that can be done with a coin. */ -enum TALER_EXCHANGEDB_TransactionType { +enum TALER_EXCHANGEDB_TransactionType +{ /** * /deposit operation. @@ -729,11 +730,14 @@ struct TALER_EXCHANGEDB_Session; typedef enum GNUNET_DB_QueryStatus (*TALER_EXCHANGEDB_DepositIterator)(void *cls, uint64_t rowid, - const struct TALER_MerchantPublicKeyP *merchant_pub, - const struct TALER_CoinSpendPublicKeyP *coin_pub, + const struct + TALER_MerchantPublicKeyP *merchant_pub, + const struct + TALER_CoinSpendPublicKeyP *coin_pub, const struct TALER_Amount *amount_with_fee, const struct TALER_Amount *deposit_fee, - const struct GNUNET_HashCode *h_contract_terms, + const struct + GNUNET_HashCode *h_contract_terms, struct GNUNET_TIME_Absolute wire_deadline, const json_t *receiver_wire_account); @@ -781,12 +785,17 @@ typedef int (*TALER_EXCHANGEDB_DepositCallback)(void *cls, uint64_t rowid, struct GNUNET_TIME_Absolute timestamp, - const struct TALER_MerchantPublicKeyP *merchant_pub, - const struct TALER_DenominationPublicKey *denom_pub, - const struct TALER_CoinSpendPublicKeyP *coin_pub, - const struct TALER_CoinSpendSignatureP *coin_sig, + const struct + TALER_MerchantPublicKeyP *merchant_pub, + const struct + TALER_DenominationPublicKey *denom_pub, + const struct + TALER_CoinSpendPublicKeyP *coin_pub, + const struct + TALER_CoinSpendSignatureP *coin_sig, const struct TALER_Amount *amount_with_fee, - const struct GNUNET_HashCode *h_contract_terms, + const struct + GNUNET_HashCode *h_contract_terms, struct GNUNET_TIME_Absolute refund_deadline, struct GNUNET_TIME_Absolute wire_deadline, const json_t *receiver_wire_account, @@ -810,12 +819,18 @@ typedef int typedef int (*TALER_EXCHANGEDB_RefreshSessionCallback)(void *cls, uint64_t rowid, - const struct TALER_DenominationPublicKey *denom_pub, - const struct TALER_CoinSpendPublicKeyP *coin_pub, - const struct TALER_CoinSpendSignatureP *coin_sig, - const struct TALER_Amount *amount_with_fee, + const struct + TALER_DenominationPublicKey * + denom_pub, + const struct + TALER_CoinSpendPublicKeyP *coin_pub, + const struct + TALER_CoinSpendSignatureP *coin_sig, + const struct + TALER_Amount *amount_with_fee, uint32_t noreveal_index, - const struct TALER_RefreshCommitmentP *rc); + const struct + TALER_RefreshCommitmentP *rc); /** @@ -833,12 +848,15 @@ typedef int */ typedef int (*TALER_EXCHANGEDB_RefundCoinCallback)(void *cls, - const struct TALER_MerchantPublicKeyP *merchant_pub, - const struct TALER_MerchantSignatureP *merchant_sig, - const struct GNUNET_HashCode *h_contract, - uint64_t rtransaction_id, - const struct TALER_Amount *amount_with_fee, - const struct TALER_Amount *refund_fee); + const struct + TALER_MerchantPublicKeyP *merchant_pub, + const struct + TALER_MerchantSignatureP *merchant_sig, + const struct GNUNET_HashCode *h_contract, + uint64_t rtransaction_id, + const struct + TALER_Amount *amount_with_fee, + const struct TALER_Amount *refund_fee); /** @@ -889,9 +907,11 @@ struct TALER_EXCHANGEDB_RefreshRevealedCoin typedef void (*TALER_EXCHANGEDB_RefreshCallback)(void *cls, uint32_t num_newcoins, - const struct TALER_EXCHANGEDB_RefreshRevealedCoin *rrcs, + const struct + TALER_EXCHANGEDB_RefreshRevealedCoin *rrcs, unsigned int num_tprivs, - const struct TALER_TransferPrivateKeyP *tprivs, + const struct + TALER_TransferPrivateKeyP *tprivs, const struct TALER_TransferPublicKeyP *tp); @@ -913,11 +933,16 @@ typedef void typedef int (*TALER_EXCHANGEDB_RefundCallback)(void *cls, uint64_t rowid, - const struct TALER_DenominationPublicKey *denom_pub, - const struct TALER_CoinSpendPublicKeyP *coin_pub, - const struct TALER_MerchantPublicKeyP *merchant_pub, - const struct TALER_MerchantSignatureP *merchant_sig, - const struct GNUNET_HashCode *h_contract_terms, + const struct + TALER_DenominationPublicKey *denom_pub, + const struct + TALER_CoinSpendPublicKeyP *coin_pub, + const struct + TALER_MerchantPublicKeyP *merchant_pub, + const struct + TALER_MerchantSignatureP *merchant_sig, + const struct + GNUNET_HashCode *h_contract_terms, uint64_t rtransaction_id, const struct TALER_Amount *amount_with_fee); @@ -938,12 +963,14 @@ typedef int typedef int (*TALER_EXCHANGEDB_ReserveInCallback)(void *cls, uint64_t rowid, - const struct TALER_ReservePublicKeyP *reserve_pub, + const struct + TALER_ReservePublicKeyP *reserve_pub, const struct TALER_Amount *credit, const char *sender_account_details, const void *wire_reference, size_t wire_reference_size, - struct GNUNET_TIME_Absolute execution_date); + struct GNUNET_TIME_Absolute + execution_date); /** @@ -964,12 +991,17 @@ typedef int (*TALER_EXCHANGEDB_WithdrawCallback)(void *cls, uint64_t rowid, const struct GNUNET_HashCode *h_blind_ev, - const struct TALER_DenominationPublicKey *denom_pub, - const struct TALER_DenominationSignature *denom_sig, - const struct TALER_ReservePublicKeyP *reserve_pub, - const struct TALER_ReserveSignatureP *reserve_sig, + const struct + TALER_DenominationPublicKey *denom_pub, + const struct + TALER_DenominationSignature *denom_sig, + const struct + TALER_ReservePublicKeyP *reserve_pub, + const struct + TALER_ReserveSignatureP *reserve_sig, struct GNUNET_TIME_Absolute execution_date, - const struct TALER_Amount *amount_with_fee); + const struct + TALER_Amount *amount_with_fee); /** @@ -982,8 +1014,10 @@ typedef int */ typedef void (*TALER_EXCHANGEDB_LinkDataCallback)(void *cls, - const struct TALER_TransferPublicKeyP *transfer_pub, - const struct TALER_EXCHANGEDB_LinkDataList *ldl); + const struct + TALER_TransferPublicKeyP *transfer_pub, + const struct + TALER_EXCHANGEDB_LinkDataList *ldl); /** @@ -1002,10 +1036,15 @@ typedef void */ typedef void (*TALER_EXCHANGEDB_TrackTransactionCallback)(void *cls, - const struct TALER_WireTransferIdentifierRawP *wtid, - const struct TALER_Amount *coin_contribution, - const struct TALER_Amount *coin_fee, - struct GNUNET_TIME_Absolute execution_time); + const struct + TALER_WireTransferIdentifierRawP * + wtid, + const struct + TALER_Amount *coin_contribution, + const struct + TALER_Amount *coin_fee, + struct GNUNET_TIME_Absolute + execution_time); /** @@ -1027,15 +1066,25 @@ typedef void typedef void (*TALER_EXCHANGEDB_WireTransferDataCallback)(void *cls, uint64_t rowid, - const struct TALER_MerchantPublicKeyP *merchant_pub, - const struct GNUNET_HashCode *h_wire, + const struct + TALER_MerchantPublicKeyP * + merchant_pub, + const struct + GNUNET_HashCode *h_wire, const json_t *account_details, - struct GNUNET_TIME_Absolute exec_time, - const struct GNUNET_HashCode *h_contract_terms, - const struct TALER_DenominationPublicKey *denom_pub, - const struct TALER_CoinSpendPublicKeyP *coin_pub, - const struct TALER_Amount *coin_value, - const struct TALER_Amount *coin_fee); + struct GNUNET_TIME_Absolute + exec_time, + const struct + GNUNET_HashCode *h_contract_terms, + const struct + TALER_DenominationPublicKey * + denom_pub, + const struct + TALER_CoinSpendPublicKeyP *coin_pub, + const struct + TALER_Amount *coin_value, + const struct + TALER_Amount *coin_fee); /** @@ -1054,7 +1103,9 @@ typedef int (*TALER_EXCHANGEDB_WireTransferOutCallback)(void *cls, uint64_t rowid, struct GNUNET_TIME_Absolute date, - const struct TALER_WireTransferIdentifierRawP *wtid, + const struct + TALER_WireTransferIdentifierRawP * + wtid, const json_t *wire, const struct TALER_Amount *amount); @@ -1097,11 +1148,15 @@ typedef int uint64_t rowid, struct GNUNET_TIME_Absolute timestamp, const struct TALER_Amount *amount, - const struct TALER_ReservePublicKeyP *reserve_pub, + const struct + TALER_ReservePublicKeyP *reserve_pub, const struct TALER_CoinPublicInfo *coin, - const struct TALER_DenominationPublicKey *denom_pub, - const struct TALER_CoinSpendSignatureP *coin_sig, - const struct TALER_DenominationBlindingKeyP *coin_blind); + const struct + TALER_DenominationPublicKey *denom_pub, + const struct + TALER_CoinSpendSignatureP *coin_sig, + const struct + TALER_DenominationBlindingKeyP *coin_blind); /** @@ -1121,13 +1176,22 @@ typedef int typedef int (*TALER_EXCHANGEDB_PaybackRefreshCallback)(void *cls, uint64_t rowid, - struct GNUNET_TIME_Absolute timestamp, + struct GNUNET_TIME_Absolute + timestamp, const struct TALER_Amount *amount, - const struct TALER_CoinSpendPublicKeyP *old_coin_pub, - const struct TALER_CoinPublicInfo *coin, - const struct TALER_DenominationPublicKey *denom_pub, - const struct TALER_CoinSpendSignatureP *coin_sig, - const struct TALER_DenominationBlindingKeyP *coin_blind); + const struct + TALER_CoinSpendPublicKeyP * + old_coin_pub, + const struct + TALER_CoinPublicInfo *coin, + const struct + TALER_DenominationPublicKey * + denom_pub, + const struct + TALER_CoinSpendSignatureP *coin_sig, + const struct + TALER_DenominationBlindingKeyP * + coin_blind); /** @@ -1146,13 +1210,18 @@ typedef int */ typedef int (*TALER_EXCHANGEDB_ReserveClosedCallback)(void *cls, - uint64_t rowid, - struct GNUNET_TIME_Absolute execution_date, - const struct TALER_Amount *amount_with_fee, - const struct TALER_Amount *closing_fee, - const struct TALER_ReservePublicKeyP *reserve_pub, - const char *receiver_account, - const struct TALER_WireTransferIdentifierRawP *wtid); + uint64_t rowid, + struct GNUNET_TIME_Absolute + execution_date, + const struct + TALER_Amount *amount_with_fee, + const struct + TALER_Amount *closing_fee, + const struct + TALER_ReservePublicKeyP *reserve_pub, + const char *receiver_account, + const struct + TALER_WireTransferIdentifierRawP *wtid); /** @@ -1167,10 +1236,12 @@ typedef int */ typedef enum GNUNET_DB_QueryStatus (*TALER_EXCHANGEDB_ReserveExpiredCallback)(void *cls, - const struct TALER_ReservePublicKeyP *reserve_pub, - const struct TALER_Amount *left, - const char *account_details, - struct GNUNET_TIME_Absolute expiration_date); + const struct + TALER_ReservePublicKeyP *reserve_pub, + const struct TALER_Amount *left, + const char *account_details, + struct GNUNET_TIME_Absolute + expiration_date); /** @@ -1188,11 +1259,18 @@ typedef enum GNUNET_DB_QueryStatus typedef void (*TALER_EXCHANGEDB_PaybackJustificationCallback)(void *cls, uint64_t rowid, - const struct TALER_CoinPublicInfo *coin, - const struct TALER_CoinSpendSignatureP *coin_sig, - const struct TALER_DenominationBlindingKeyP *coin_blind, - const struct GNUNET_HashCode *h_blinded_ev, - const struct TALER_Amount *amount); + const struct + TALER_CoinPublicInfo *coin, + const struct + TALER_CoinSpendSignatureP * + coin_sig, + const struct + TALER_DenominationBlindingKeyP + *coin_blind, + const struct + GNUNET_HashCode *h_blinded_ev, + const struct + TALER_Amount *amount); /** @@ -1210,13 +1288,14 @@ typedef void */ typedef void (*TALER_EXCHANGEDB_WireMissingCallback)(void *cls, - uint64_t rowid, - const struct TALER_CoinSpendPublicKeyP *coin_pub, - const struct TALER_Amount *amount, - const json_t *wire, - struct GNUNET_TIME_Absolute deadline, - /* bool? */ int tiny, - /* bool? */ int done); + uint64_t rowid, + const struct + TALER_CoinSpendPublicKeyP *coin_pub, + const struct TALER_Amount *amount, + const json_t *wire, + struct GNUNET_TIME_Absolute deadline, + /* bool? */ int tiny, + /* bool? */ int done); /** @@ -1228,8 +1307,12 @@ typedef void */ typedef void (*TALER_EXCHANGEDB_DenominationInfoIterator)(void *cls, - const struct TALER_DenominationPublicKey *denom_pub, - const struct TALER_EXCHANGEDB_DenominationKeyInformationP *issue); + const struct + TALER_DenominationPublicKey * + denom_pub, + const struct + TALER_EXCHANGEDB_DenominationKeyInformationP + *issue); /** @@ -1304,8 +1387,8 @@ struct TALER_EXCHANGEDB_Plugin * @return transaction status */ enum GNUNET_DB_QueryStatus - (*commit) (void *cls, - struct TALER_EXCHANGEDB_Session *session); + (*commit)(void *cls, + struct TALER_EXCHANGEDB_Session *session); /** @@ -1344,10 +1427,13 @@ struct TALER_EXCHANGEDB_Plugin * @return status of the query */ enum GNUNET_DB_QueryStatus - (*insert_denomination_info) (void *cls, - struct TALER_EXCHANGEDB_Session *session, - const struct TALER_DenominationPublicKey *denom_pub, - const struct TALER_EXCHANGEDB_DenominationKeyInformationP *issue); + (*insert_denomination_info)(void *cls, + struct TALER_EXCHANGEDB_Session *session, + const struct + TALER_DenominationPublicKey *denom_pub, + const struct + TALER_EXCHANGEDB_DenominationKeyInformationP * + issue); /** @@ -1360,10 +1446,11 @@ struct TALER_EXCHANGEDB_Plugin * @return transaction status code */ enum GNUNET_DB_QueryStatus - (*get_denomination_info) (void *cls, - struct TALER_EXCHANGEDB_Session *session, - const struct GNUNET_HashCode *denom_pub_hash, - struct TALER_EXCHANGEDB_DenominationKeyInformationP *issue); + (*get_denomination_info)(void *cls, + struct TALER_EXCHANGEDB_Session *session, + const struct GNUNET_HashCode *denom_pub_hash, + struct TALER_EXCHANGEDB_DenominationKeyInformationP * + issue); /** @@ -1376,9 +1463,9 @@ struct TALER_EXCHANGEDB_Plugin * @return transaction status code */ enum GNUNET_DB_QueryStatus - (*iterate_denomination_info) (void *cls, - TALER_EXCHANGEDB_DenominationInfoIterator cb, - void *cb_cls); + (*iterate_denomination_info)(void *cls, + TALER_EXCHANGEDB_DenominationInfoIterator cb, + void *cb_cls); /** * Get the summary of a reserve. @@ -1391,9 +1478,9 @@ struct TALER_EXCHANGEDB_Plugin * @return transaction status */ enum GNUNET_DB_QueryStatus - (*reserve_get) (void *cls, - struct TALER_EXCHANGEDB_Session *db, - struct TALER_EXCHANGEDB_Reserve *reserve); + (*reserve_get)(void *cls, + struct TALER_EXCHANGEDB_Session *db, + struct TALER_EXCHANGEDB_Reserve *reserve); /** @@ -1413,15 +1500,15 @@ struct TALER_EXCHANGEDB_Plugin * @return transaction status code */ enum GNUNET_DB_QueryStatus - (*reserves_in_insert) (void *cls, - struct TALER_EXCHANGEDB_Session *db, - const struct TALER_ReservePublicKeyP *reserve_pub, - const struct TALER_Amount *balance, - struct GNUNET_TIME_Absolute execution_time, - const char *sender_account_details, - const char *exchange_account_name, - const void *wire_reference, - size_t wire_reference_size); + (*reserves_in_insert)(void *cls, + struct TALER_EXCHANGEDB_Session *db, + const struct TALER_ReservePublicKeyP *reserve_pub, + const struct TALER_Amount *balance, + struct GNUNET_TIME_Absolute execution_time, + const char *sender_account_details, + const char *exchange_account_name, + const void *wire_reference, + size_t wire_reference_size); /** @@ -1454,10 +1541,10 @@ struct TALER_EXCHANGEDB_Plugin * @return statement execution status */ enum GNUNET_DB_QueryStatus - (*get_withdraw_info) (void *cls, - struct TALER_EXCHANGEDB_Session *session, - const struct GNUNET_HashCode *h_blind, - struct TALER_EXCHANGEDB_CollectableBlindcoin *collectable); + (*get_withdraw_info)(void *cls, + struct TALER_EXCHANGEDB_Session *session, + const struct GNUNET_HashCode *h_blind, + struct TALER_EXCHANGEDB_CollectableBlindcoin *collectable); /** @@ -1471,9 +1558,10 @@ struct TALER_EXCHANGEDB_Plugin * @return statement execution status */ enum GNUNET_DB_QueryStatus - (*insert_withdraw_info) (void *cls, - struct TALER_EXCHANGEDB_Session *session, - const struct TALER_EXCHANGEDB_CollectableBlindcoin *collectable); + (*insert_withdraw_info)(void *cls, + struct TALER_EXCHANGEDB_Session *session, + const struct + TALER_EXCHANGEDB_CollectableBlindcoin *collectable); /** @@ -1487,10 +1575,10 @@ struct TALER_EXCHANGEDB_Plugin * @return transaction status */ enum GNUNET_DB_QueryStatus - (*get_reserve_history) (void *cls, - struct TALER_EXCHANGEDB_Session *session, - const struct TALER_ReservePublicKeyP *reserve_pub, - struct TALER_EXCHANGEDB_ReserveHistory **rhp); + (*get_reserve_history)(void *cls, + struct TALER_EXCHANGEDB_Session *session, + const struct TALER_ReservePublicKeyP *reserve_pub, + struct TALER_EXCHANGEDB_ReserveHistory **rhp); /** @@ -1527,9 +1615,9 @@ struct TALER_EXCHANGEDB_Plugin * @return database transaction status, non-negative on success */ enum GNUNET_DB_QueryStatus - (*ensure_coin_known) (void *cls, - struct TALER_EXCHANGEDB_Session *session, - const struct TALER_CoinPublicInfo *coin); + (*ensure_coin_known)(void *cls, + struct TALER_EXCHANGEDB_Session *session, + const struct TALER_CoinPublicInfo *coin); /** @@ -1541,10 +1629,10 @@ struct TALER_EXCHANGEDB_Plugin * @return database transaction status, non-negative on success */ enum GNUNET_DB_QueryStatus - (*get_known_coin) (void *cls, - struct TALER_EXCHANGEDB_Session *session, - const struct TALER_CoinSpendPublicKeyP *coin_pub, - struct TALER_CoinPublicInfo *coin_info); + (*get_known_coin)(void *cls, + struct TALER_EXCHANGEDB_Session *session, + const struct TALER_CoinSpendPublicKeyP *coin_pub, + struct TALER_CoinPublicInfo *coin_info); /** * Check if we have the specified deposit already in the database. @@ -1558,10 +1646,10 @@ struct TALER_EXCHANGEDB_Plugin * otherwise transaction error status */ enum GNUNET_DB_QueryStatus - (*have_deposit) (void *cls, - struct TALER_EXCHANGEDB_Session *session, - const struct TALER_EXCHANGEDB_Deposit *deposit, - int check_extras); + (*have_deposit)(void *cls, + struct TALER_EXCHANGEDB_Session *session, + const struct TALER_EXCHANGEDB_Deposit *deposit, + int check_extras); /** @@ -1573,9 +1661,9 @@ struct TALER_EXCHANGEDB_Plugin * @return query result status */ enum GNUNET_DB_QueryStatus - (*insert_deposit) (void *cls, - struct TALER_EXCHANGEDB_Session *session, - const struct TALER_EXCHANGEDB_Deposit *deposit); + (*insert_deposit)(void *cls, + struct TALER_EXCHANGEDB_Session *session, + const struct TALER_EXCHANGEDB_Deposit *deposit); /** @@ -1587,9 +1675,9 @@ struct TALER_EXCHANGEDB_Plugin * @return query result status */ enum GNUNET_DB_QueryStatus - (*insert_refund) (void *cls, - struct TALER_EXCHANGEDB_Session *session, - const struct TALER_EXCHANGEDB_Refund *refund); + (*insert_refund)(void *cls, + struct TALER_EXCHANGEDB_Session *session, + const struct TALER_EXCHANGEDB_Refund *refund); /** * Select refunds by @a coin_pub. @@ -1603,10 +1691,10 @@ struct TALER_EXCHANGEDB_Plugin */ enum GNUNET_DB_QueryStatus (*select_refunds_by_coin)(void *cls, - struct TALER_EXCHANGEDB_Session *session, - const struct TALER_CoinSpendPublicKeyP *coin_pub, - TALER_EXCHANGEDB_RefundCoinCallback cb, - void *cb_cls); + struct TALER_EXCHANGEDB_Session *session, + const struct TALER_CoinSpendPublicKeyP *coin_pub, + TALER_EXCHANGEDB_RefundCoinCallback cb, + void *cb_cls); /** @@ -1620,9 +1708,9 @@ struct TALER_EXCHANGEDB_Plugin * @return query result status */ enum GNUNET_DB_QueryStatus - (*mark_deposit_tiny) (void *cls, - struct TALER_EXCHANGEDB_Session *session, - uint64_t rowid); + (*mark_deposit_tiny)(void *cls, + struct TALER_EXCHANGEDB_Session *session, + uint64_t rowid); /** @@ -1637,9 +1725,9 @@ struct TALER_EXCHANGEDB_Plugin * otherwise transaction error status (incl. deposit unknown) */ enum GNUNET_DB_QueryStatus - (*test_deposit_done) (void *cls, - struct TALER_EXCHANGEDB_Session *session, - const struct TALER_EXCHANGEDB_Deposit *deposit); + (*test_deposit_done)(void *cls, + struct TALER_EXCHANGEDB_Session *session, + const struct TALER_EXCHANGEDB_Deposit *deposit); /** @@ -1653,9 +1741,9 @@ struct TALER_EXCHANGEDB_Plugin * @return query result status */ enum GNUNET_DB_QueryStatus - (*mark_deposit_done) (void *cls, - struct TALER_EXCHANGEDB_Session *session, - uint64_t rowid); + (*mark_deposit_done)(void *cls, + struct TALER_EXCHANGEDB_Session *session, + uint64_t rowid); /** @@ -1670,10 +1758,10 @@ struct TALER_EXCHANGEDB_Plugin * @return transaction status code */ enum GNUNET_DB_QueryStatus - (*get_ready_deposit) (void *cls, - struct TALER_EXCHANGEDB_Session *session, - TALER_EXCHANGEDB_DepositIterator deposit_cb, - void *deposit_cb_cls); + (*get_ready_deposit)(void *cls, + struct TALER_EXCHANGEDB_Session *session, + TALER_EXCHANGEDB_DepositIterator deposit_cb, + void *deposit_cb_cls); /** @@ -1704,13 +1792,14 @@ struct TALER_EXCHANGEDB_Plugin * transaction status code on error */ enum GNUNET_DB_QueryStatus - (*iterate_matching_deposits) (void *cls, - struct TALER_EXCHANGEDB_Session *session, - const struct GNUNET_HashCode *h_wire, - const struct TALER_MerchantPublicKeyP *merchant_pub, - TALER_EXCHANGEDB_DepositIterator deposit_cb, - void *deposit_cb_cls, - uint32_t limit); + (*iterate_matching_deposits)(void *cls, + struct TALER_EXCHANGEDB_Session *session, + const struct GNUNET_HashCode *h_wire, + const struct + TALER_MerchantPublicKeyP *merchant_pub, + TALER_EXCHANGEDB_DepositIterator deposit_cb, + void *deposit_cb_cls, + uint32_t limit); /** @@ -1722,9 +1811,9 @@ struct TALER_EXCHANGEDB_Plugin * @return query status for the transaction */ enum GNUNET_DB_QueryStatus - (*insert_melt) (void *cls, - struct TALER_EXCHANGEDB_Session *session, - const struct TALER_EXCHANGEDB_RefreshSession *refresh_session); + (*insert_melt)(void *cls, + struct TALER_EXCHANGEDB_Session *session, + const struct TALER_EXCHANGEDB_RefreshSession *refresh_session); /** @@ -1737,10 +1826,10 @@ struct TALER_EXCHANGEDB_Plugin * @return transaction status */ enum GNUNET_DB_QueryStatus - (*get_melt) (void *cls, - struct TALER_EXCHANGEDB_Session *session, - const struct TALER_RefreshCommitmentP *rc, - struct TALER_EXCHANGEDB_RefreshMelt *refresh_melt); + (*get_melt)(void *cls, + struct TALER_EXCHANGEDB_Session *session, + const struct TALER_RefreshCommitmentP *rc, + struct TALER_EXCHANGEDB_RefreshMelt *refresh_melt); /** @@ -1754,10 +1843,10 @@ struct TALER_EXCHANGEDB_Plugin * @return transaction status */ enum GNUNET_DB_QueryStatus - (*get_melt_index) (void *cls, - struct TALER_EXCHANGEDB_Session *session, - const struct TALER_RefreshCommitmentP *rc, - uint32_t *noreveal_index); + (*get_melt_index)(void *cls, + struct TALER_EXCHANGEDB_Session *session, + const struct TALER_RefreshCommitmentP *rc, + uint32_t *noreveal_index); /** @@ -1777,14 +1866,15 @@ struct TALER_EXCHANGEDB_Plugin * @return query status for the transaction */ enum GNUNET_DB_QueryStatus - (*insert_refresh_reveal) (void *cls, - struct TALER_EXCHANGEDB_Session *session, - const struct TALER_RefreshCommitmentP *rc, - uint32_t num_rrcs, - const struct TALER_EXCHANGEDB_RefreshRevealedCoin *rrcs, - unsigned int num_tprivs, - const struct TALER_TransferPrivateKeyP *tprivs, - const struct TALER_TransferPublicKeyP *tp); + (*insert_refresh_reveal)(void *cls, + struct TALER_EXCHANGEDB_Session *session, + const struct TALER_RefreshCommitmentP *rc, + uint32_t num_rrcs, + const struct + TALER_EXCHANGEDB_RefreshRevealedCoin *rrcs, + unsigned int num_tprivs, + const struct TALER_TransferPrivateKeyP *tprivs, + const struct TALER_TransferPublicKeyP *tp); /** @@ -1799,11 +1889,11 @@ struct TALER_EXCHANGEDB_Plugin * @return transaction status */ enum GNUNET_DB_QueryStatus - (*get_refresh_reveal) (void *cls, - struct TALER_EXCHANGEDB_Session *session, - const struct TALER_RefreshCommitmentP *rc, - TALER_EXCHANGEDB_RefreshCallback cb, - void *cb_cls); + (*get_refresh_reveal)(void *cls, + struct TALER_EXCHANGEDB_Session *session, + const struct TALER_RefreshCommitmentP *rc, + TALER_EXCHANGEDB_RefreshCallback cb, + void *cb_cls); /** @@ -1820,11 +1910,11 @@ struct TALER_EXCHANGEDB_Plugin * @return statement execution status */ enum GNUNET_DB_QueryStatus - (*get_link_data) (void *cls, - struct TALER_EXCHANGEDB_Session *session, - const struct TALER_CoinSpendPublicKeyP *coin_pub, - TALER_EXCHANGEDB_LinkDataCallback ldc, - void *tdc_cls); + (*get_link_data)(void *cls, + struct TALER_EXCHANGEDB_Session *session, + const struct TALER_CoinSpendPublicKeyP *coin_pub, + TALER_EXCHANGEDB_LinkDataCallback ldc, + void *tdc_cls); /** @@ -1839,11 +1929,11 @@ struct TALER_EXCHANGEDB_Plugin * @return database transaction status */ enum GNUNET_DB_QueryStatus - (*get_coin_transactions) (void *cls, - struct TALER_EXCHANGEDB_Session *session, - const struct TALER_CoinSpendPublicKeyP *coin_pub, - int include_payback, - struct TALER_EXCHANGEDB_TransactionList **tlp); + (*get_coin_transactions)(void *cls, + struct TALER_EXCHANGEDB_Session *session, + const struct TALER_CoinSpendPublicKeyP *coin_pub, + int include_payback, + struct TALER_EXCHANGEDB_TransactionList **tlp); /** @@ -1869,11 +1959,11 @@ struct TALER_EXCHANGEDB_Plugin * @return query status of the transaction */ enum GNUNET_DB_QueryStatus - (*lookup_wire_transfer) (void *cls, - struct TALER_EXCHANGEDB_Session *session, - const struct TALER_WireTransferIdentifierRawP *wtid, - TALER_EXCHANGEDB_WireTransferDataCallback cb, - void *cb_cls); + (*lookup_wire_transfer)(void *cls, + struct TALER_EXCHANGEDB_Session *session, + const struct TALER_WireTransferIdentifierRawP *wtid, + TALER_EXCHANGEDB_WireTransferDataCallback cb, + void *cb_cls); /** @@ -1894,12 +1984,13 @@ struct TALER_EXCHANGEDB_Plugin enum GNUNET_DB_QueryStatus (*wire_lookup_deposit_wtid)(void *cls, struct TALER_EXCHANGEDB_Session *session, - const struct GNUNET_HashCode *h_contract_terms, - const struct GNUNET_HashCode *h_wire, - const struct TALER_CoinSpendPublicKeyP *coin_pub, - const struct TALER_MerchantPublicKeyP *merchant_pub, - TALER_EXCHANGEDB_TrackTransactionCallback cb, - void *cb_cls); + const struct GNUNET_HashCode *h_contract_terms, + const struct GNUNET_HashCode *h_wire, + const struct TALER_CoinSpendPublicKeyP *coin_pub, + const struct + TALER_MerchantPublicKeyP *merchant_pub, + TALER_EXCHANGEDB_TrackTransactionCallback cb, + void *cb_cls); /** @@ -1914,7 +2005,8 @@ struct TALER_EXCHANGEDB_Plugin enum GNUNET_DB_QueryStatus (*insert_aggregation_tracking)(void *cls, struct TALER_EXCHANGEDB_Session *session, - const struct TALER_WireTransferIdentifierRawP *wtid, + const struct + TALER_WireTransferIdentifierRawP *wtid, unsigned long long deposit_serial_id); @@ -1957,15 +2049,15 @@ struct TALER_EXCHANGEDB_Plugin * @return query status of the transaction */ enum GNUNET_DB_QueryStatus - (*get_wire_fee) (void *cls, - struct TALER_EXCHANGEDB_Session *session, - const char *type, - struct GNUNET_TIME_Absolute date, - struct GNUNET_TIME_Absolute *start_date, - struct GNUNET_TIME_Absolute *end_date, - struct TALER_Amount *wire_fee, - struct TALER_Amount *closing_fee, - struct TALER_MasterSignatureP *master_sig); + (*get_wire_fee)(void *cls, + struct TALER_EXCHANGEDB_Session *session, + const char *type, + struct GNUNET_TIME_Absolute date, + struct GNUNET_TIME_Absolute *start_date, + struct GNUNET_TIME_Absolute *end_date, + struct TALER_Amount *wire_fee, + struct TALER_Amount *closing_fee, + struct TALER_MasterSignatureP *master_sig); /** @@ -2093,7 +2185,8 @@ struct TALER_EXCHANGEDB_Plugin (*store_wire_transfer_out)(void *cls, struct TALER_EXCHANGEDB_Session *session, struct GNUNET_TIME_Absolute date, - const struct TALER_WireTransferIdentifierRawP *wtid, + const struct + TALER_WireTransferIdentifierRawP *wtid, const json_t *wire_account, const char *exchange_account_section, const struct TALER_Amount *amount); @@ -2207,10 +2300,13 @@ struct TALER_EXCHANGEDB_Plugin */ enum GNUNET_DB_QueryStatus (*select_reserves_in_above_serial_id_by_account)(void *cls, - struct TALER_EXCHANGEDB_Session *session, + struct + TALER_EXCHANGEDB_Session * + session, const char *account_name, uint64_t serial_id, - TALER_EXCHANGEDB_ReserveInCallback cb, + TALER_EXCHANGEDB_ReserveInCallback + cb, void *cb_cls); /** @@ -2227,7 +2323,8 @@ struct TALER_EXCHANGEDB_Plugin */ enum GNUNET_DB_QueryStatus (*select_reserves_out_above_serial_id)(void *cls, - struct TALER_EXCHANGEDB_Session *session, + struct TALER_EXCHANGEDB_Session * + session, uint64_t serial_id, TALER_EXCHANGEDB_WithdrawCallback cb, void *cb_cls); @@ -2264,10 +2361,12 @@ struct TALER_EXCHANGEDB_Plugin */ enum GNUNET_DB_QueryStatus (*select_wire_out_above_serial_id_by_account)(void *cls, - struct TALER_EXCHANGEDB_Session *session, + struct TALER_EXCHANGEDB_Session + *session, const char *account_name, uint64_t serial_id, - TALER_EXCHANGEDB_WireTransferOutCallback cb, + TALER_EXCHANGEDB_WireTransferOutCallback + cb, void *cb_cls); @@ -2303,9 +2402,11 @@ struct TALER_EXCHANGEDB_Plugin */ enum GNUNET_DB_QueryStatus (*select_payback_refresh_above_serial_id)(void *cls, - struct TALER_EXCHANGEDB_Session *session, + struct TALER_EXCHANGEDB_Session * + session, uint64_t serial_id, - TALER_EXCHANGEDB_PaybackRefreshCallback cb, + TALER_EXCHANGEDB_PaybackRefreshCallback + cb, void *cb_cls); @@ -2322,9 +2423,11 @@ struct TALER_EXCHANGEDB_Plugin */ enum GNUNET_DB_QueryStatus (*select_reserve_closed_above_serial_id)(void *cls, - struct TALER_EXCHANGEDB_Session *session, + struct TALER_EXCHANGEDB_Session * + session, uint64_t serial_id, - TALER_EXCHANGEDB_ReserveClosedCallback cb, + TALER_EXCHANGEDB_ReserveClosedCallback + cb, void *cb_cls); @@ -2350,7 +2453,8 @@ struct TALER_EXCHANGEDB_Plugin const struct TALER_ReservePublicKeyP *reserve_pub, const struct TALER_CoinPublicInfo *coin, const struct TALER_CoinSpendSignatureP *coin_sig, - const struct TALER_DenominationBlindingKeyP *coin_blind, + const struct + TALER_DenominationBlindingKeyP *coin_blind, const struct TALER_Amount *amount, const struct GNUNET_HashCode *h_blind_ev, struct GNUNET_TIME_Absolute timestamp); @@ -2375,8 +2479,10 @@ struct TALER_EXCHANGEDB_Plugin (*insert_payback_refresh_request)(void *cls, struct TALER_EXCHANGEDB_Session *session, const struct TALER_CoinPublicInfo *coin, - const struct TALER_CoinSpendSignatureP *coin_sig, - const struct TALER_DenominationBlindingKeyP *coin_blind, + const struct + TALER_CoinSpendSignatureP *coin_sig, + const struct + TALER_DenominationBlindingKeyP *coin_blind, const struct TALER_Amount *amount, const struct GNUNET_HashCode *h_blind_ev, struct GNUNET_TIME_Absolute timestamp); @@ -2429,8 +2535,10 @@ struct TALER_EXCHANGEDB_Plugin enum GNUNET_DB_QueryStatus (*insert_denomination_revocation)(void *cls, struct TALER_EXCHANGEDB_Session *session, - const struct GNUNET_HashCode *denom_pub_hash, - const struct TALER_MasterSignatureP *master_sig); + const struct + GNUNET_HashCode *denom_pub_hash, + const struct + TALER_MasterSignatureP *master_sig); /** diff --git a/src/include/taler_json_lib.h b/src/include/taler_json_lib.h index 53dbec3cf..382bb19ee 100644 --- a/src/include/taler_json_lib.h +++ b/src/include/taler_json_lib.h @@ -77,7 +77,7 @@ TALER_JSON_spec_amount (const char *name, */ struct GNUNET_JSON_Specification TALER_JSON_spec_amount_nbo (const char *name, - struct TALER_AmountNBO *r_amount); + struct TALER_AmountNBO *r_amount); /** @@ -163,7 +163,8 @@ TALER_JSON_exchange_wire_signature_hash (const json_t *wire_s, */ int TALER_JSON_exchange_wire_signature_check (const json_t *wire_s, - const struct TALER_MasterPublicKeyP *master_pub); + const struct + TALER_MasterPublicKeyP *master_pub); /** @@ -174,7 +175,8 @@ TALER_JSON_exchange_wire_signature_check (const json_t *wire_s, */ json_t * TALER_JSON_exchange_wire_signature_make (const char *payto_url, - const struct TALER_MasterPrivateKeyP *master_priv); + const struct + TALER_MasterPrivateKeyP *master_priv); /** diff --git a/src/include/taler_pq_lib.h b/src/include/taler_pq_lib.h index 47040ea02..697917568 100644 --- a/src/include/taler_pq_lib.h +++ b/src/include/taler_pq_lib.h @@ -87,7 +87,8 @@ TALER_PQ_query_param_absolute_time (const struct GNUNET_TIME_Absolute *x); * @param x pointer to the query parameter to pass */ struct GNUNET_PQ_QueryParam -TALER_PQ_query_param_absolute_time_nbo (const struct GNUNET_TIME_AbsoluteNBO *x); +TALER_PQ_query_param_absolute_time_nbo (const struct + GNUNET_TIME_AbsoluteNBO *x); /** diff --git a/src/include/taler_testing_auditor_lib.h b/src/include/taler_testing_auditor_lib.h index 090a1210c..b12cce986 100644 --- a/src/include/taler_testing_auditor_lib.h +++ b/src/include/taler_testing_auditor_lib.h @@ -87,13 +87,12 @@ TALER_TESTING_cmd_exec_wire_auditor (const char *label, * @return the command. */ struct TALER_TESTING_Command -TALER_TESTING_cmd_deposit_confirmation - (const char *label, - struct TALER_AUDITOR_Handle *auditor, - const char *deposit_reference, - unsigned int coin_index, - const char *amount_without_fee, - unsigned int expected_response_code); +TALER_TESTING_cmd_deposit_confirmation (const char *label, + struct TALER_AUDITOR_Handle *auditor, + const char *deposit_reference, + unsigned int coin_index, + const char *amount_without_fee, + unsigned int expected_response_code); /** @@ -104,7 +103,8 @@ TALER_TESTING_cmd_deposit_confirmation * @return the command with retries enabled */ struct TALER_TESTING_Command -TALER_TESTING_cmd_deposit_confirmation_with_retry (struct TALER_TESTING_Command cmd); +TALER_TESTING_cmd_deposit_confirmation_with_retry (struct TALER_TESTING_Command + cmd); /** @@ -116,10 +116,9 @@ TALER_TESTING_cmd_deposit_confirmation_with_retry (struct TALER_TESTING_Command * @return the command. */ struct TALER_TESTING_Command -TALER_TESTING_cmd_exchanges - (const char *label, - struct TALER_AUDITOR_Handle *auditor, - unsigned int expected_response_code); +TALER_TESTING_cmd_exchanges (const char *label, + struct TALER_AUDITOR_Handle *auditor, + unsigned int expected_response_code); /** @@ -134,10 +133,9 @@ TALER_TESTING_cmd_exchanges * @return the command. */ struct TALER_TESTING_Command -TALER_TESTING_cmd_exchanges_with_url - (const char *label, - unsigned int expected_response_code, - const char *exchange_url); +TALER_TESTING_cmd_exchanges_with_url (const char *label, + unsigned int expected_response_code, + const char *exchange_url); /** * Modify an exchanges command to enable retries when we get diff --git a/src/include/taler_testing_bank_lib.h b/src/include/taler_testing_bank_lib.h index 5beaf97f6..9948a7f2d 100644 --- a/src/include/taler_testing_bank_lib.h +++ b/src/include/taler_testing_bank_lib.h @@ -95,19 +95,18 @@ TALER_TESTING_prepare_bank (const char *config_filename); * @param start_row_reference reference to a command that can * offer a row identifier, to be used as the starting row * to accept in the result. - * @param num_result how many rows we want in the result. + * @param num_result how many rows we want in the result. * * @return the command. */ struct TALER_TESTING_Command -TALER_TESTING_cmd_bank_history - (const char *label, - const char *bank_url, - uint64_t account_no, - enum TALER_BANK_Direction direction, - unsigned int ascending, - const char *start_row_reference, - long long num_results); +TALER_TESTING_cmd_bank_history (const char *label, + const char *bank_url, + uint64_t account_no, + enum TALER_BANK_Direction direction, + unsigned int ascending, + const char *start_row_reference, + long long num_results); /** @@ -127,14 +126,16 @@ TALER_TESTING_cmd_bank_history * @return the command. */ struct TALER_TESTING_Command -TALER_TESTING_cmd_bank_history_range_with_dates - (const char *label, - const char *bank_url, - uint64_t account_no, - enum TALER_BANK_Direction direction, - unsigned int ascending, - struct GNUNET_TIME_Absolute start_date, - struct GNUNET_TIME_Absolute end_date); +TALER_TESTING_cmd_bank_history_range_with_dates (const char *label, + const char *bank_url, + uint64_t account_no, + enum TALER_BANK_Direction + direction, + unsigned int ascending, + struct GNUNET_TIME_Absolute + start_date, + struct GNUNET_TIME_Absolute + end_date); /** @@ -156,14 +157,13 @@ TALER_TESTING_cmd_bank_history_range_with_dates * @return the command. */ struct TALER_TESTING_Command -TALER_TESTING_cmd_bank_history_range - (const char *label, - const char *bank_url, - uint64_t account_no, - enum TALER_BANK_Direction direction, - unsigned int ascending, - const char *start_row_reference, - const char *end_row_reference); +TALER_TESTING_cmd_bank_history_range (const char *label, + const char *bank_url, + uint64_t account_no, + enum TALER_BANK_Direction direction, + unsigned int ascending, + const char *start_row_reference, + const char *end_row_reference); /** diff --git a/src/include/taler_testing_lib.h b/src/include/taler_testing_lib.h index 41cc8b501..4f69a0d01 100644 --- a/src/include/taler_testing_lib.h +++ b/src/include/taler_testing_lib.h @@ -41,7 +41,7 @@ */ #define TALER_TESTING_FAIL(is) \ do \ - {\ + { \ GNUNET_break (0); \ TALER_TESTING_interpreter_fail (is); \ return; \ @@ -113,8 +113,8 @@ TALER_TESTING_find_pk (const struct TALER_EXCHANGE_Keys *keys, */ int TALER_TESTING_prepare_exchange (const char *config_filename, - char **auditor_base_url, - char **exchange_base_url); + char **auditor_base_url, + char **exchange_base_url); /** * "Canonical" cert_cb used when we are connecting to the @@ -126,10 +126,9 @@ TALER_TESTING_prepare_exchange (const char *config_filename, * @param compat protocol compatibility information. */ void -TALER_TESTING_cert_cb - (void *cls, - const struct TALER_EXCHANGE_Keys *keys, - enum TALER_EXCHANGE_VersionCompatibility compat); +TALER_TESTING_cert_cb (void *cls, + const struct TALER_EXCHANGE_Keys *keys, + enum TALER_EXCHANGE_VersionCompatibility compat); /** @@ -174,7 +173,7 @@ TALER_TESTING_cleanup_files (const char *config_name); */ int TALER_TESTING_cleanup_files_cfg (void *cls, - const struct GNUNET_CONFIGURATION_Handle *cfg); + const struct GNUNET_CONFIGURATION_Handle *cfg); /** @@ -186,7 +185,7 @@ TALER_TESTING_cleanup_files_cfg (void *cls, */ int TALER_TESTING_run_keyup (const char *config_filename, - const char *output_filename); + const char *output_filename); /** @@ -221,10 +220,10 @@ TALER_TESTING_exchange_db_reset (const char *config_filename); */ int TALER_TESTING_run_auditor_sign (const char *config_filename, - const char *exchange_master_pub, - const char *auditor_base_url, - const char *signdata_in, - const char *signdata_out); + const char *exchange_master_pub, + const char *auditor_base_url, + const char *signdata_in, + const char *signdata_out); /** @@ -464,9 +463,8 @@ struct TALER_TESTING_Command * @return the command, if it is found, or NULL. */ const struct TALER_TESTING_Command * -TALER_TESTING_interpreter_lookup_command - (struct TALER_TESTING_Interpreter *i, - const char *label); +TALER_TESTING_interpreter_lookup_command (struct TALER_TESTING_Interpreter *i, + const char *label); /** * Obtain main execution context for the main loop. @@ -475,8 +473,7 @@ TALER_TESTING_interpreter_lookup_command * @return CURL execution context. */ struct GNUNET_CURL_Context * -TALER_TESTING_interpreter_get_context - (struct TALER_TESTING_Interpreter *is); +TALER_TESTING_interpreter_get_context (struct TALER_TESTING_Interpreter *is); /** * Obtain label of the command being now run. @@ -485,8 +482,8 @@ TALER_TESTING_interpreter_get_context * @return the label. */ const char * -TALER_TESTING_interpreter_get_current_label - (struct TALER_TESTING_Interpreter *is); +TALER_TESTING_interpreter_get_current_label (struct + TALER_TESTING_Interpreter *is); @@ -497,8 +494,7 @@ TALER_TESTING_interpreter_get_current_label * @return the handle. */ struct TALER_FAKEBANK_Handle * -TALER_TESTING_interpreter_get_fakebank - (struct TALER_TESTING_Interpreter *is); +TALER_TESTING_interpreter_get_fakebank (struct TALER_TESTING_Interpreter *is); /** * Current command is done, run the next one. @@ -506,8 +502,7 @@ TALER_TESTING_interpreter_get_fakebank * @param is interpreter state. */ void -TALER_TESTING_interpreter_next - (struct TALER_TESTING_Interpreter *is); +TALER_TESTING_interpreter_next (struct TALER_TESTING_Interpreter *is); /** * Current command failed, clean up and fail the test case. @@ -515,8 +510,7 @@ TALER_TESTING_interpreter_next * @param is interpreter state. */ void -TALER_TESTING_interpreter_fail - (struct TALER_TESTING_Interpreter *is); +TALER_TESTING_interpreter_fail (struct TALER_TESTING_Interpreter *is); /** * Create command array terminator. @@ -536,8 +530,7 @@ TALER_TESTING_cmd_end (); * @param is interpreter state. */ void -TALER_TESTING_wait_for_sigchld - (struct TALER_TESTING_Interpreter *is); +TALER_TESTING_wait_for_sigchld (struct TALER_TESTING_Interpreter *is); /** @@ -576,10 +569,9 @@ TALER_TESTING_run2 (struct TALER_TESTING_Interpreter *is, * @param bank_url base URL of the fake bank. */ void -TALER_TESTING_run_with_fakebank - (struct TALER_TESTING_Interpreter *is, - struct TALER_TESTING_Command *commands, - const char *bank_url); +TALER_TESTING_run_with_fakebank (struct TALER_TESTING_Interpreter *is, + struct TALER_TESTING_Command *commands, + const char *bank_url); /** @@ -655,9 +647,9 @@ struct TALER_TESTING_SetupContext * @return #GNUNET_OK if no errors occurred. */ int -TALER_TESTING_setup_with_exchange_cfg - (void *cls, - const struct GNUNET_CONFIGURATION_Handle *cfg); +TALER_TESTING_setup_with_exchange_cfg (void *cls, + const struct + GNUNET_CONFIGURATION_Handle *cfg); /** @@ -691,9 +683,10 @@ TALER_TESTING_setup_with_exchange (TALER_TESTING_Main main_cb, * @return #GNUNET_OK if no errors occurred. */ int -TALER_TESTING_setup_with_auditor_and_exchange_cfg - (void *cls, - const struct GNUNET_CONFIGURATION_Handle *cfg); +TALER_TESTING_setup_with_auditor_and_exchange_cfg (void *cls, + const struct + GNUNET_CONFIGURATION_Handle * + cfg); /** @@ -712,10 +705,9 @@ TALER_TESTING_setup_with_auditor_and_exchange_cfg * @return #GNUNET_OK if no errors occurred. */ int -TALER_TESTING_setup_with_auditor_and_exchange - (TALER_TESTING_Main main_cb, - void *main_cb_cls, - const char *config_file); +TALER_TESTING_setup_with_auditor_and_exchange (TALER_TESTING_Main main_cb, + void *main_cb_cls, + const char *config_file); /* ************** Specific interpreter commands ************ */ @@ -778,16 +770,15 @@ TALER_TESTING_cmd_fakebank_transfer (const char *label, * @return the command. */ struct TALER_TESTING_Command -TALER_TESTING_cmd_fakebank_transfer_with_subject - (const char *label, - const char *amount, - const char *bank_url, - uint64_t debit_account_no, - uint64_t credit_account_no, - const char *auth_username, - const char *auth_password, - const char *subject, - const char *exchange_url); +TALER_TESTING_cmd_fakebank_transfer_with_subject (const char *label, + const char *amount, + const char *bank_url, + uint64_t debit_account_no, + uint64_t credit_account_no, + const char *auth_username, + const char *auth_password, + const char *subject, + const char *exchange_url); /** @@ -814,16 +805,15 @@ TALER_TESTING_cmd_fakebank_transfer_with_subject * @return the command. */ struct TALER_TESTING_Command -TALER_TESTING_cmd_fakebank_transfer_with_ref - (const char *label, - const char *amount, - const char *bank_url, - uint64_t debit_account_no, - uint64_t credit_account_no, - const char *auth_username, - const char *auth_password, - const char *ref, - const char *exchange_url); +TALER_TESTING_cmd_fakebank_transfer_with_ref (const char *label, + const char *amount, + const char *bank_url, + uint64_t debit_account_no, + uint64_t credit_account_no, + const char *auth_username, + const char *auth_password, + const char *ref, + const char *exchange_url); /** @@ -858,17 +848,16 @@ TALER_TESTING_cmd_fakebank_transfer_with_ref * @return the command. */ struct TALER_TESTING_Command -TALER_TESTING_cmd_fakebank_transfer_with_instance - (const char *label, - const char *amount, - const char *bank_url, - uint64_t debit_account_no, - uint64_t credit_account_no, - const char *auth_username, - const char *auth_password, - const char *instance, - const char *exchange_url, - const char *config_filename); +TALER_TESTING_cmd_fakebank_transfer_with_instance (const char *label, + const char *amount, + const char *bank_url, + uint64_t debit_account_no, + uint64_t credit_account_no, + const char *auth_username, + const char *auth_password, + const char *instance, + const char *exchange_url, + const char *config_filename); /** @@ -880,8 +869,7 @@ TALER_TESTING_cmd_fakebank_transfer_with_instance * @return the command with retries enabled */ struct TALER_TESTING_Command -TALER_TESTING_cmd_fakebank_transfer_retry - (struct TALER_TESTING_Command cmd); +TALER_TESTING_cmd_fakebank_transfer_retry (struct TALER_TESTING_Command cmd); /** @@ -931,10 +919,9 @@ TALER_TESTING_cmd_exec_keyup (const char *label, * @return the command. */ struct TALER_TESTING_Command -TALER_TESTING_cmd_exec_keyup_with_now - (const char *label, - const char *config_filename, - struct GNUNET_TIME_Absolute now); +TALER_TESTING_cmd_exec_keyup_with_now (const char *label, + const char *config_filename, + struct GNUNET_TIME_Absolute now); /** @@ -954,11 +941,10 @@ TALER_TESTING_cmd_exec_keyup_with_now * @return the command. */ struct TALER_TESTING_Command -TALER_TESTING_cmd_check_keys_with_now - (const char *label, - unsigned int generation, - unsigned int num_denom_keys, - struct GNUNET_TIME_Absolute now); +TALER_TESTING_cmd_check_keys_with_now (const char *label, + unsigned int generation, + unsigned int num_denom_keys, + struct GNUNET_TIME_Absolute now); /** @@ -986,11 +972,10 @@ TALER_TESTING_cmd_exec_auditor_sign (const char *label, * @return the withdraw command to be executed by the interpreter. */ struct TALER_TESTING_Command -TALER_TESTING_cmd_withdraw_amount - (const char *label, - const char *reserve_reference, - const char *amount, - unsigned int expected_response_code); +TALER_TESTING_cmd_withdraw_amount (const char *label, + const char *reserve_reference, + const char *amount, + unsigned int expected_response_code); /** @@ -1006,11 +991,11 @@ TALER_TESTING_cmd_withdraw_amount * @return the command. */ struct TALER_TESTING_Command -TALER_TESTING_cmd_withdraw_denomination - (const char *label, - const char *reserve_reference, - const struct TALER_EXCHANGE_DenomPublicKey *dk, - unsigned int expected_response_code); +TALER_TESTING_cmd_withdraw_denomination (const char *label, + const char *reserve_reference, + const struct + TALER_EXCHANGE_DenomPublicKey *dk, + unsigned int expected_response_code); /** @@ -1022,8 +1007,7 @@ TALER_TESTING_cmd_withdraw_denomination * @return the command with retries enabled */ struct TALER_TESTING_Command -TALER_TESTING_cmd_withdraw_with_retry - (struct TALER_TESTING_Command cmd); +TALER_TESTING_cmd_withdraw_with_retry (struct TALER_TESTING_Command cmd); /** @@ -1082,15 +1066,14 @@ TALER_TESTING_cmd_status (const char *label, * @return the command. */ struct TALER_TESTING_Command -TALER_TESTING_cmd_deposit - (const char *label, - const char *coin_reference, - unsigned int coin_index, - json_t *wire_details, - const char *contract_terms, - struct GNUNET_TIME_Relative refund_deadline, - const char *amount, - unsigned int expected_response_code); +TALER_TESTING_cmd_deposit (const char *label, + const char *coin_reference, + unsigned int coin_index, + json_t *wire_details, + const char *contract_terms, + struct GNUNET_TIME_Relative refund_deadline, + const char *amount, + unsigned int expected_response_code); /** @@ -1101,8 +1084,7 @@ TALER_TESTING_cmd_deposit * @return the command with retries enabled */ struct TALER_TESTING_Command -TALER_TESTING_cmd_deposit_with_retry - (struct TALER_TESTING_Command cmd); +TALER_TESTING_cmd_deposit_with_retry (struct TALER_TESTING_Command cmd); /** @@ -1116,11 +1098,10 @@ TALER_TESTING_cmd_deposit_with_retry * @return the command. */ struct TALER_TESTING_Command -TALER_TESTING_cmd_refresh_melt - (const char *label, - const char *coin_reference, - unsigned int expected_response_code, - ...); +TALER_TESTING_cmd_refresh_melt (const char *label, + const char *coin_reference, + unsigned int expected_response_code, + ...); /** @@ -1136,11 +1117,10 @@ TALER_TESTING_cmd_refresh_melt * @return the command. */ struct TALER_TESTING_Command -TALER_TESTING_cmd_refresh_melt_double - (const char *label, - const char *coin_reference, - unsigned int expected_response_code, - ...); +TALER_TESTING_cmd_refresh_melt_double (const char *label, + const char *coin_reference, + unsigned int expected_response_code, + ...); /** @@ -1150,8 +1130,7 @@ TALER_TESTING_cmd_refresh_melt_double * @return modified command. */ struct TALER_TESTING_Command -TALER_TESTING_cmd_refresh_melt_with_retry - (struct TALER_TESTING_Command cmd); +TALER_TESTING_cmd_refresh_melt_with_retry (struct TALER_TESTING_Command cmd); /** @@ -1165,10 +1144,9 @@ TALER_TESTING_cmd_refresh_melt_with_retry * @return the command. */ struct TALER_TESTING_Command -TALER_TESTING_cmd_refresh_reveal - (const char *label, - const char *melt_reference, - unsigned int expected_response_code); +TALER_TESTING_cmd_refresh_reveal (const char *label, + const char *melt_reference, + unsigned int expected_response_code); /** @@ -1192,10 +1170,9 @@ TALER_TESTING_cmd_refresh_reveal_with_retry (struct TALER_TESTING_Command cmd); * @return the "refresh link" command */ struct TALER_TESTING_Command -TALER_TESTING_cmd_refresh_link - (const char *label, - const char *reveal_reference, - unsigned int expected_response_code); +TALER_TESTING_cmd_refresh_link (const char *label, + const char *reveal_reference, + unsigned int expected_response_code); /** @@ -1223,12 +1200,11 @@ TALER_TESTING_cmd_refresh_link_with_retry (struct TALER_TESTING_Command cmd); * @return the command. */ struct TALER_TESTING_Command -TALER_TESTING_cmd_track_transaction - (const char *label, - const char *transaction_reference, - unsigned int coin_index, - unsigned int expected_response_code, - const char *bank_transfer_reference); +TALER_TESTING_cmd_track_transaction (const char *label, + const char *transaction_reference, + unsigned int coin_index, + unsigned int expected_response_code, + const char *bank_transfer_reference); /** * Make a "track transfer" CMD where no "expected"-arguments, @@ -1248,11 +1224,10 @@ TALER_TESTING_cmd_track_transaction * @return the command. */ struct TALER_TESTING_Command -TALER_TESTING_cmd_track_transfer_empty - (const char *label, - const char *wtid_reference, - unsigned int index, - unsigned int expected_response_code); +TALER_TESTING_cmd_track_transfer_empty (const char *label, + const char *wtid_reference, + unsigned int index, + unsigned int expected_response_code); /** @@ -1272,13 +1247,12 @@ TALER_TESTING_cmd_track_transfer_empty * @return the command */ struct TALER_TESTING_Command -TALER_TESTING_cmd_track_transfer - (const char *label, - const char *wtid_reference, - unsigned int index, - unsigned int expected_response_code, - const char *expected_total_amount, - const char *expected_wire_fee); +TALER_TESTING_cmd_track_transfer (const char *label, + const char *wtid_reference, + unsigned int index, + unsigned int expected_response_code, + const char *expected_total_amount, + const char *expected_wire_fee); /** * Make a "bank check" CMD. It checks whether a @@ -1294,12 +1268,11 @@ TALER_TESTING_cmd_track_transfer * @return the command */ struct TALER_TESTING_Command -TALER_TESTING_cmd_check_bank_transfer - (const char *label, - const char *exchange_base_url, - const char *amount, - uint64_t debit_account, - uint64_t credit_account); +TALER_TESTING_cmd_check_bank_transfer (const char *label, + const char *exchange_base_url, + const char *amount, + uint64_t debit_account, + uint64_t credit_account); @@ -1315,9 +1288,8 @@ TALER_TESTING_cmd_check_bank_transfer * @return the command. */ struct TALER_TESTING_Command -TALER_TESTING_cmd_check_bank_transfer_with_ref - (const char *label, - const char *deposit_reference); +TALER_TESTING_cmd_check_bank_transfer_with_ref (const char *label, + const char *deposit_reference); /** @@ -1348,13 +1320,12 @@ TALER_TESTING_cmd_check_bank_empty (const char *label); * @return the command. */ struct TALER_TESTING_Command -TALER_TESTING_cmd_refund_with_id - (const char *label, - unsigned int expected_response_code, - const char *refund_amount, - const char *refund_fee, - const char *deposit_reference, - uint64_t refund_transaction_id); +TALER_TESTING_cmd_refund_with_id (const char *label, + unsigned int expected_response_code, + const char *refund_amount, + const char *refund_fee, + const char *deposit_reference, + uint64_t refund_transaction_id); /** @@ -1468,10 +1439,9 @@ TALER_TESTING_cmd_wait_service (const char *label, * @return the command. */ struct TALER_TESTING_Command -TALER_TESTING_cmd_check_keys - (const char *label, - unsigned int generation, - unsigned int num_denom_keys); +TALER_TESTING_cmd_check_keys (const char *label, + unsigned int generation, + unsigned int num_denom_keys); /** @@ -1491,10 +1461,9 @@ TALER_TESTING_cmd_check_keys * @return the command. */ struct TALER_TESTING_Command -TALER_TESTING_cmd_check_keys_pull_all_keys - (const char *label, - unsigned int generation, - unsigned int num_denom_keys); +TALER_TESTING_cmd_check_keys_pull_all_keys (const char *label, + unsigned int generation, + unsigned int num_denom_keys); /** @@ -1518,11 +1487,11 @@ TALER_TESTING_cmd_check_keys_pull_all_keys * @return the command. */ struct TALER_TESTING_Command -TALER_TESTING_cmd_check_keys_with_last_denom - (const char *label, - unsigned int generation, - unsigned int num_denom_keys, - struct GNUNET_TIME_Absolute last_denom_date); +TALER_TESTING_cmd_check_keys_with_last_denom (const char *label, + unsigned int generation, + unsigned int num_denom_keys, + struct GNUNET_TIME_Absolute + last_denom_date); /** @@ -1556,8 +1525,7 @@ TALER_TESTING_cmd_is_batch (const struct TALER_TESTING_Command *cmd); * @param is interpreter state. */ void -TALER_TESTING_cmd_batch_next - (struct TALER_TESTING_Interpreter *is); +TALER_TESTING_cmd_batch_next (struct TALER_TESTING_Interpreter *is); /** * Obtain what command the batch is at. @@ -1656,9 +1624,9 @@ TALER_TESTING_get_trait (const struct TALER_TESTING_Trait *traits, */ struct TALER_TESTING_Trait -TALER_TESTING_make_trait_reserve_priv - (unsigned int index, - const struct TALER_ReservePrivateKeyP *reserve_priv); +TALER_TESTING_make_trait_reserve_priv (unsigned int index, + const struct + TALER_ReservePrivateKeyP *reserve_priv); /** @@ -1671,10 +1639,10 @@ TALER_TESTING_make_trait_reserve_priv * @return #GNUNET_OK on success. */ int -TALER_TESTING_get_trait_reserve_priv - (const struct TALER_TESTING_Command *cmd, - unsigned int index, - const struct TALER_ReservePrivateKeyP **reserve_priv); +TALER_TESTING_get_trait_reserve_priv (const struct TALER_TESTING_Command *cmd, + unsigned int index, + const struct + TALER_ReservePrivateKeyP **reserve_priv); /** @@ -1686,9 +1654,9 @@ TALER_TESTING_get_trait_reserve_priv * @return the trait. */ struct TALER_TESTING_Trait -TALER_TESTING_make_trait_exchange_sig - (unsigned int index, - const struct TALER_ExchangeSignatureP *exchange_sig); +TALER_TESTING_make_trait_exchange_sig (unsigned int index, + const struct + TALER_ExchangeSignatureP *exchange_sig); /** @@ -1700,10 +1668,10 @@ TALER_TESTING_make_trait_exchange_sig * @return #GNUNET_OK on success. */ int -TALER_TESTING_get_trait_exchange_sig - (const struct TALER_TESTING_Command *cmd, - unsigned int index, - const struct TALER_ExchangeSignatureP **exchange_sig); +TALER_TESTING_get_trait_exchange_sig (const struct TALER_TESTING_Command *cmd, + unsigned int index, + const struct + TALER_ExchangeSignatureP **exchange_sig); /** @@ -1715,9 +1683,9 @@ TALER_TESTING_get_trait_exchange_sig * @return the trait. */ struct TALER_TESTING_Trait -TALER_TESTING_make_trait_exchange_pub - (unsigned int index, - const struct TALER_ExchangePublicKeyP *exchange_pub); +TALER_TESTING_make_trait_exchange_pub (unsigned int index, + const struct + TALER_ExchangePublicKeyP *exchange_pub); /** @@ -1729,10 +1697,10 @@ TALER_TESTING_make_trait_exchange_pub * @return #GNUNET_OK on success. */ int -TALER_TESTING_get_trait_exchange_pub - (const struct TALER_TESTING_Command *cmd, - unsigned int index, - const struct TALER_ExchangePublicKeyP **exchange_pub); +TALER_TESTING_get_trait_exchange_pub (const struct TALER_TESTING_Command *cmd, + unsigned int index, + const struct + TALER_ExchangePublicKeyP **exchange_pub); /** @@ -1747,10 +1715,9 @@ TALER_TESTING_get_trait_exchange_pub * @return #GNUNET_OK on success. */ int -TALER_TESTING_get_trait_process - (const struct TALER_TESTING_Command *cmd, - unsigned int index, - struct GNUNET_OS_Process ***processp); // FIXME: why is this a ***!? ** should do! +TALER_TESTING_get_trait_process (const struct TALER_TESTING_Command *cmd, + unsigned int index, + struct GNUNET_OS_Process ***processp); // FIXME: why is this a ***!? ** should do! /** @@ -1763,9 +1730,8 @@ TALER_TESTING_get_trait_process * @return the trait. */ struct TALER_TESTING_Trait -TALER_TESTING_make_trait_process - (unsigned int index, - struct GNUNET_OS_Process **processp); // FIXME: why is this a "**"? * should do! +TALER_TESTING_make_trait_process (unsigned int index, + struct GNUNET_OS_Process **processp); // FIXME: why is this a "**"? * should do! /** @@ -1777,9 +1743,9 @@ TALER_TESTING_make_trait_process * @return the trait. */ struct TALER_TESTING_Trait -TALER_TESTING_make_trait_coin_priv - (unsigned int index, - const struct TALER_CoinSpendPrivateKeyP *coin_priv); +TALER_TESTING_make_trait_coin_priv (unsigned int index, + const struct + TALER_CoinSpendPrivateKeyP *coin_priv); /** * Obtain a coin private key from a @a cmd. @@ -1791,10 +1757,10 @@ TALER_TESTING_make_trait_coin_priv * @return #GNUNET_OK on success. */ int -TALER_TESTING_get_trait_coin_priv - (const struct TALER_TESTING_Command *cmd, - unsigned int index, - const struct TALER_CoinSpendPrivateKeyP **coin_priv); +TALER_TESTING_get_trait_coin_priv (const struct TALER_TESTING_Command *cmd, + unsigned int index, + const struct + TALER_CoinSpendPrivateKeyP **coin_priv); /** @@ -1806,9 +1772,10 @@ TALER_TESTING_get_trait_coin_priv * @return the trait. */ struct TALER_TESTING_Trait -TALER_TESTING_make_trait_blinding_key - (unsigned int index, - const struct TALER_DenominationBlindingKeyP *blinding_key); +TALER_TESTING_make_trait_blinding_key (unsigned int index, + const struct + TALER_DenominationBlindingKeyP * + blinding_key); /** @@ -1821,10 +1788,11 @@ TALER_TESTING_make_trait_blinding_key * @return #GNUNET_OK on success. */ int -TALER_TESTING_get_trait_blinding_key - (const struct TALER_TESTING_Command *cmd, - unsigned int index, - const struct TALER_DenominationBlindingKeyP **blinding_key); +TALER_TESTING_get_trait_blinding_key (const struct TALER_TESTING_Command *cmd, + unsigned int index, + const struct + TALER_DenominationBlindingKeyP ** + blinding_key); /** @@ -1836,9 +1804,9 @@ TALER_TESTING_get_trait_blinding_key * @return the trait. */ struct TALER_TESTING_Trait -TALER_TESTING_make_trait_denom_pub - (unsigned int index, - const struct TALER_EXCHANGE_DenomPublicKey *dpk); +TALER_TESTING_make_trait_denom_pub (unsigned int index, + const struct + TALER_EXCHANGE_DenomPublicKey *dpk); /** @@ -1851,10 +1819,10 @@ TALER_TESTING_make_trait_denom_pub * @return #GNUNET_OK on success. */ int -TALER_TESTING_get_trait_denom_pub - (const struct TALER_TESTING_Command *cmd, - unsigned int index, - const struct TALER_EXCHANGE_DenomPublicKey **dpk); +TALER_TESTING_get_trait_denom_pub (const struct TALER_TESTING_Command *cmd, + unsigned int index, + const struct + TALER_EXCHANGE_DenomPublicKey **dpk); /** @@ -1867,10 +1835,10 @@ TALER_TESTING_get_trait_denom_pub * @return #GNUNET_OK on success. */ int -TALER_TESTING_get_trait_denom_sig - (const struct TALER_TESTING_Command *cmd, - unsigned int index, - const struct TALER_DenominationSignature **dpk); +TALER_TESTING_get_trait_denom_sig (const struct TALER_TESTING_Command *cmd, + unsigned int index, + const struct + TALER_DenominationSignature **dpk); /** @@ -1883,9 +1851,9 @@ TALER_TESTING_get_trait_denom_sig * @return the trait. */ struct TALER_TESTING_Trait -TALER_TESTING_make_trait_denom_sig - (unsigned int index, - const struct TALER_DenominationSignature *sig); +TALER_TESTING_make_trait_denom_sig (unsigned int index, + const struct + TALER_DenominationSignature *sig); /** @@ -1895,9 +1863,8 @@ TALER_TESTING_make_trait_denom_sig * @param n number to offer. */ struct TALER_TESTING_Trait -TALER_TESTING_make_trait_uint64 - (unsigned int index, - const uint64_t *n); +TALER_TESTING_make_trait_uint64 (unsigned int index, + const uint64_t *n); /** @@ -1910,10 +1877,9 @@ TALER_TESTING_make_trait_uint64 * @return #GNUNET_OK on success. */ int -TALER_TESTING_get_trait_uint64 - (const struct TALER_TESTING_Command *cmd, - unsigned int index, - const uint64_t **n); +TALER_TESTING_get_trait_uint64 (const struct TALER_TESTING_Command *cmd, + unsigned int index, + const uint64_t **n); /** @@ -1925,9 +1891,8 @@ TALER_TESTING_get_trait_uint64 * @return #GNUNET_OK on success. */ struct TALER_TESTING_Trait -TALER_TESTING_make_trait_uint - (unsigned int index, - const unsigned int *i); +TALER_TESTING_make_trait_uint (unsigned int index, + const unsigned int *i); /** @@ -1940,10 +1905,9 @@ TALER_TESTING_make_trait_uint * @return #GNUNET_OK on success. */ int -TALER_TESTING_get_trait_uint - (const struct TALER_TESTING_Command *cmd, - unsigned int index, - const unsigned int **n); +TALER_TESTING_get_trait_uint (const struct TALER_TESTING_Command *cmd, + unsigned int index, + const unsigned int **n); /** @@ -1990,9 +1954,9 @@ struct TALER_TESTING_FreshCoinData * @return the trait, */ struct TALER_TESTING_Trait -TALER_TESTING_make_trait_fresh_coins - (unsigned int index, - struct TALER_TESTING_FreshCoinData *fresh_coins); +TALER_TESTING_make_trait_fresh_coins (unsigned int index, + struct TALER_TESTING_FreshCoinData * + fresh_coins); /** @@ -2006,10 +1970,10 @@ TALER_TESTING_make_trait_fresh_coins * @return #GNUNET_OK on success. */ int -TALER_TESTING_get_trait_fresh_coins - (const struct TALER_TESTING_Command *cmd, - unsigned int index, - const struct TALER_TESTING_FreshCoinData **fresh_coins); +TALER_TESTING_get_trait_fresh_coins (const struct TALER_TESTING_Command *cmd, + unsigned int index, + const struct + TALER_TESTING_FreshCoinData **fresh_coins); /** @@ -2022,10 +1986,9 @@ TALER_TESTING_get_trait_fresh_coins * @return #GNUNET_OK on success. */ int -TALER_TESTING_get_trait_contract_terms - (const struct TALER_TESTING_Command *cmd, - unsigned int index, - const json_t **contract_terms); +TALER_TESTING_get_trait_contract_terms (const struct TALER_TESTING_Command *cmd, + unsigned int index, + const json_t **contract_terms); /** @@ -2036,9 +1999,8 @@ TALER_TESTING_get_trait_contract_terms * @return the trait. */ struct TALER_TESTING_Trait -TALER_TESTING_make_trait_contract_terms - (unsigned int index, - const json_t *contract_terms); +TALER_TESTING_make_trait_contract_terms (unsigned int index, + const json_t *contract_terms); /** @@ -2053,10 +2015,9 @@ TALER_TESTING_make_trait_contract_terms * @return #GNUNET_OK on success. */ int -TALER_TESTING_get_trait_wire_details - (const struct TALER_TESTING_Command *cmd, - unsigned int index, - const json_t **wire_details); +TALER_TESTING_get_trait_wire_details (const struct TALER_TESTING_Command *cmd, + unsigned int index, + const json_t **wire_details); /** @@ -2070,9 +2031,8 @@ TALER_TESTING_get_trait_wire_details * @return the trait. */ struct TALER_TESTING_Trait -TALER_TESTING_make_trait_wire_details - (unsigned int index, - const json_t *wire_details); +TALER_TESTING_make_trait_wire_details (unsigned int index, + const json_t *wire_details); /** @@ -2084,10 +2044,9 @@ TALER_TESTING_make_trait_wire_details * @return #GNUNET_OK on success. */ int -TALER_TESTING_get_trait_exchange_keys - (const struct TALER_TESTING_Command *cmd, - unsigned int index, - const json_t **keys); +TALER_TESTING_get_trait_exchange_keys (const struct TALER_TESTING_Command *cmd, + unsigned int index, + const json_t **keys); /** @@ -2099,9 +2058,8 @@ TALER_TESTING_get_trait_exchange_keys * @return the trait. */ struct TALER_TESTING_Trait -TALER_TESTING_make_trait_exchange_keys - (unsigned int index, - const json_t *keys); +TALER_TESTING_make_trait_exchange_keys (unsigned int index, + const json_t *keys); /** @@ -2115,10 +2073,10 @@ TALER_TESTING_make_trait_exchange_keys * @return #GNUNET_OK on success. */ int -TALER_TESTING_get_trait_peer_key - (const struct TALER_TESTING_Command *cmd, - unsigned int index, - const struct GNUNET_CRYPTO_EddsaPrivateKey **priv); +TALER_TESTING_get_trait_peer_key (const struct TALER_TESTING_Command *cmd, + unsigned int index, + const struct + GNUNET_CRYPTO_EddsaPrivateKey **priv); // FIXME: private get_trait_merchant_priv instead, rather have // more traits with precise types than this! @@ -2133,9 +2091,9 @@ TALER_TESTING_get_trait_peer_key * @return the trait. */ struct TALER_TESTING_Trait -TALER_TESTING_make_trait_peer_key - (unsigned int index, - const struct GNUNET_CRYPTO_EddsaPrivateKey *priv); +TALER_TESTING_make_trait_peer_key (unsigned int index, + const struct + GNUNET_CRYPTO_EddsaPrivateKey *priv); // FIXME: private get_trait_merchant_priv instead, rather have // more traits with precise types than this! @@ -2152,10 +2110,10 @@ TALER_TESTING_make_trait_peer_key * @return #GNUNET_OK on success. */ int -TALER_TESTING_get_trait_peer_key_pub - (const struct TALER_TESTING_Command *cmd, - unsigned int index, - const struct GNUNET_CRYPTO_EddsaPublicKey **pub); +TALER_TESTING_get_trait_peer_key_pub (const struct TALER_TESTING_Command *cmd, + unsigned int index, + const struct + GNUNET_CRYPTO_EddsaPublicKey **pub); /** @@ -2169,9 +2127,8 @@ TALER_TESTING_get_trait_peer_key_pub * @return the trait. */ struct TALER_TESTING_Trait -TALER_TESTING_make_trait_peer_key_pub - (unsigned int index, - struct GNUNET_CRYPTO_EddsaPublicKey *pub); +TALER_TESTING_make_trait_peer_key_pub (unsigned int index, + struct GNUNET_CRYPTO_EddsaPublicKey *pub); /** @@ -2186,10 +2143,10 @@ TALER_TESTING_make_trait_peer_key_pub * @return #GNUNET_OK on success. */ int -TALER_TESTING_get_trait_transfer_subject - (const struct TALER_TESTING_Command *cmd, - unsigned int index, - const char **transfer_subject); +TALER_TESTING_get_trait_transfer_subject (const struct + TALER_TESTING_Command *cmd, + unsigned int index, + const char **transfer_subject); /** @@ -2201,9 +2158,8 @@ TALER_TESTING_get_trait_transfer_subject * @return the trait. */ struct TALER_TESTING_Trait -TALER_TESTING_make_trait_transfer_subject - (unsigned int index, - const char *transfer_subject); +TALER_TESTING_make_trait_transfer_subject (unsigned int index, + const char *transfer_subject); /** @@ -2216,10 +2172,10 @@ TALER_TESTING_make_trait_transfer_subject * @return #GNUNET_OK on success */ int -TALER_TESTING_get_trait_wtid - (const struct TALER_TESTING_Command *cmd, - unsigned int index, - const struct TALER_WireTransferIdentifierRawP **wtid); +TALER_TESTING_get_trait_wtid (const struct TALER_TESTING_Command *cmd, + unsigned int index, + const struct + TALER_WireTransferIdentifierRawP **wtid); /** @@ -2230,9 +2186,9 @@ TALER_TESTING_get_trait_wtid * @return the trait. */ struct TALER_TESTING_Trait -TALER_TESTING_make_trait_wtid - (unsigned int index, - const struct TALER_WireTransferIdentifierRawP *wtid); +TALER_TESTING_make_trait_wtid (unsigned int index, + const struct + TALER_WireTransferIdentifierRawP *wtid); /** @@ -2244,9 +2200,8 @@ TALER_TESTING_make_trait_wtid * @return the trait. */ struct TALER_TESTING_Trait -TALER_TESTING_make_trait_amount - (unsigned int index, - const char *amount); +TALER_TESTING_make_trait_amount (unsigned int index, + const char *amount); /** @@ -2260,10 +2215,9 @@ TALER_TESTING_make_trait_amount * @return #GNUNET_OK on success. */ int -TALER_TESTING_get_trait_amount - (const struct TALER_TESTING_Command *cmd, - unsigned int index, - const char **amount); +TALER_TESTING_get_trait_amount (const struct TALER_TESTING_Command *cmd, + unsigned int index, + const char **amount); /** @@ -2276,9 +2230,8 @@ TALER_TESTING_get_trait_amount * @return the trait. */ struct TALER_TESTING_Trait -TALER_TESTING_make_trait_url - (unsigned int index, - const char *url); +TALER_TESTING_make_trait_url (unsigned int index, + const char *url); /** @@ -2292,10 +2245,9 @@ TALER_TESTING_make_trait_url * @return #GNUNET_OK on success. */ int -TALER_TESTING_get_trait_url - (const struct TALER_TESTING_Command *cmd, - unsigned int index, - const char **url); +TALER_TESTING_get_trait_url (const struct TALER_TESTING_Command *cmd, + unsigned int index, + const char **url); /** @@ -2309,10 +2261,9 @@ TALER_TESTING_get_trait_url * @return #GNUNET_OK on success. */ int -TALER_TESTING_get_trait_order_id - (const struct TALER_TESTING_Command *cmd, - unsigned int index, - const char **order_id); +TALER_TESTING_get_trait_order_id (const struct TALER_TESTING_Command *cmd, + unsigned int index, + const char **order_id); /** @@ -2325,9 +2276,8 @@ TALER_TESTING_get_trait_order_id * @return the trait. */ struct TALER_TESTING_Trait -TALER_TESTING_make_trait_order_id - (unsigned int index, - const char *order_id); +TALER_TESTING_make_trait_order_id (unsigned int index, + const char *order_id); /** @@ -2341,10 +2291,9 @@ TALER_TESTING_make_trait_order_id * @return #GNUNET_OK on success */ int -TALER_TESTING_get_trait_amount_obj - (const struct TALER_TESTING_Command *cmd, - unsigned int index, - const struct TALER_Amount **amount); +TALER_TESTING_get_trait_amount_obj (const struct TALER_TESTING_Command *cmd, + unsigned int index, + const struct TALER_Amount **amount); /** @@ -2357,9 +2306,8 @@ TALER_TESTING_get_trait_amount_obj * @return the trait. */ struct TALER_TESTING_Trait -TALER_TESTING_make_trait_amount_obj - (unsigned int index, - const struct TALER_Amount *amount); +TALER_TESTING_make_trait_amount_obj (unsigned int index, + const struct TALER_Amount *amount); /** @@ -2372,9 +2320,8 @@ TALER_TESTING_make_trait_amount_obj * @return the trait. */ struct TALER_TESTING_Trait -TALER_TESTING_make_trait_rejected - (unsigned int index, - const char *rejected); +TALER_TESTING_make_trait_rejected (unsigned int index, + const char *rejected); /** @@ -2389,10 +2336,9 @@ TALER_TESTING_make_trait_rejected * @return #GNUNET_OK on success. */ int -TALER_TESTING_get_trait_rejected - (const struct TALER_TESTING_Command *cmd, - unsigned int index, - const char **rejected_reference); +TALER_TESTING_get_trait_rejected (const struct TALER_TESTING_Command *cmd, + unsigned int index, + const char **rejected_reference); /** @@ -2407,9 +2353,8 @@ TALER_TESTING_get_trait_rejected * @return the trait. */ struct TALER_TESTING_Trait -TALER_TESTING_make_trait_cmd - (unsigned int index, - const struct TALER_TESTING_Command *cmd); +TALER_TESTING_make_trait_cmd (unsigned int index, + const struct TALER_TESTING_Command *cmd); /** @@ -2425,10 +2370,9 @@ TALER_TESTING_make_trait_cmd * @return #GNUNET_OK on success. */ int -TALER_TESTING_get_trait_cmd - (const struct TALER_TESTING_Command *cmd, - unsigned int index, - struct TALER_TESTING_Command **_cmd); +TALER_TESTING_get_trait_cmd (const struct TALER_TESTING_Command *cmd, + unsigned int index, + struct TALER_TESTING_Command **_cmd); /** @@ -2441,10 +2385,10 @@ TALER_TESTING_get_trait_cmd * @return #GNUNET_OK on success */ int -TALER_TESTING_get_trait_absolute_time - (const struct TALER_TESTING_Command *cmd, - unsigned int index, - const struct GNUNET_TIME_Absolute **time); +TALER_TESTING_get_trait_absolute_time (const struct TALER_TESTING_Command *cmd, + unsigned int index, + const struct + GNUNET_TIME_Absolute **time); /** @@ -2455,8 +2399,8 @@ TALER_TESTING_get_trait_absolute_time * @return the trait. */ struct TALER_TESTING_Trait -TALER_TESTING_make_trait_absolute_time - (unsigned int index, - const struct GNUNET_TIME_Absolute *time); +TALER_TESTING_make_trait_absolute_time (unsigned int index, + const struct + GNUNET_TIME_Absolute *time); #endif diff --git a/src/include/taler_util.h b/src/include/taler_util.h index 479a45754..310c88955 100644 --- a/src/include/taler_util.h +++ b/src/include/taler_util.h @@ -51,9 +51,9 @@ #define TALER_assert_as(EXP, reason) \ do { \ if (EXP) break; \ - TALER_LOG_ERROR("%s at %s:%d\n", reason, __FILE__, __LINE__); \ - abort(); \ - } while(0) + TALER_LOG_ERROR ("%s at %s:%d\n", reason, __FILE__, __LINE__); \ + abort (); \ + } while (0) /** @@ -61,11 +61,17 @@ * a failure of the command 'cmd' with the message given * by gcry_strerror(rc). */ -#define TALER_LOG_GCRY_ERROR(cmd, rc) do { TALER_LOG_ERROR("`%s' failed at %s:%d with error: %s\n", cmd, __FILE__, __LINE__, gcry_strerror(rc)); } while(0) +#define TALER_LOG_GCRY_ERROR(cmd, rc) do { TALER_LOG_ERROR ( \ + "`%s' failed at %s:%d with error: %s\n", \ + cmd, __FILE__, __LINE__, \ + gcry_strerror (rc)); } while (0) #define TALER_gcry_ok(cmd) \ - do {int rc; rc = cmd; if (!rc) break; TALER_LOG_ERROR("A Gcrypt call failed at %s:%d with error: %s\n", __FILE__, __LINE__, gcry_strerror(rc)); abort(); } while (0) + do {int rc; rc = cmd; if (! rc) break; \ + TALER_LOG_ERROR ("A Gcrypt call failed at %s:%d with error: %s\n", \ + __FILE__, \ + __LINE__, gcry_strerror (rc)); abort (); } while (0) /** diff --git a/src/include/taler_util_wallet.h b/src/include/taler_util_wallet.h index dd08702db..249ee4571 100644 --- a/src/include/taler_util_wallet.h +++ b/src/include/taler_util_wallet.h @@ -55,9 +55,9 @@ extern "C" #define TALER_assert_as(EXP, reason) \ do { \ if (EXP) break; \ - TALER_LOG_ERROR("%s at %s:%d\n", reason, __FILE__, __LINE__); \ - abort(); \ - } while(0) + TALER_LOG_ERROR ("%s at %s:%d\n", reason, __FILE__, __LINE__); \ + abort (); \ + } while (0) /** @@ -65,11 +65,17 @@ extern "C" * a failure of the command 'cmd' with the message given * by gcry_strerror(rc). */ -#define TALER_LOG_GCRY_ERROR(cmd, rc) do { TALER_LOG_ERROR("`%s' failed at %s:%d with error: %s\n", cmd, __FILE__, __LINE__, gcry_strerror(rc)); } while(0) +#define TALER_LOG_GCRY_ERROR(cmd, rc) do { TALER_LOG_ERROR ( \ + "`%s' failed at %s:%d with error: %s\n", \ + cmd, __FILE__, __LINE__, \ + gcry_strerror (rc)); } while (0) #define TALER_gcry_ok(cmd) \ - do {int rc; rc = cmd; if (!rc) break; TALER_LOG_ERROR("A Gcrypt call failed at %s:%d with error: %s\n", __FILE__, __LINE__, gcry_strerror(rc)); abort(); } while (0) + do {int rc; rc = cmd; if (! rc) break; \ + TALER_LOG_ERROR ("A Gcrypt call failed at %s:%d with error: %s\n", \ + __FILE__, \ + __LINE__, gcry_strerror (rc)); abort (); } while (0) /** diff --git a/src/include/taler_wire_lib.h b/src/include/taler_wire_lib.h index 835ea7ca5..3c8510919 100644 --- a/src/include/taler_wire_lib.h +++ b/src/include/taler_wire_lib.h @@ -28,23 +28,23 @@ * Different account types supported by payto://. */ enum TALER_PaytoAccountType - { +{ - /** - * Used to indicate an uninitialized struct. - */ - TALER_PAC_NONE = 0, + /** + * Used to indicate an uninitialized struct. + */ + TALER_PAC_NONE = 0, - /** - * Account type of a bank running the x-taler-bank protocol. - */ - TALER_PAC_X_TALER_BANK, + /** + * Account type of a bank running the x-taler-bank protocol. + */ + TALER_PAC_X_TALER_BANK, - /** - * Account identified by IBAN number. - */ - TALER_PAC_IBAN - }; + /** + * Account identified by IBAN number. + */ + TALER_PAC_IBAN +}; /** * Information about an account extracted from a payto://-URL. @@ -60,13 +60,15 @@ struct TALER_Account /** * Internals depending on @e type. */ - union { + union + { /** * Taler bank address from x-taler-bank. Set if * @e type is #TALER_AC_X_TALER_BANK. */ - struct { + struct + { /** * Hostname of the bank (possibly including port). @@ -88,7 +90,8 @@ struct TALER_Account * Taler bank address from iban. Set if * @e type is #TALER_AC_IBAN. */ - struct { + struct + { /** * IBAN number. diff --git a/src/include/taler_wire_plugin.h b/src/include/taler_wire_plugin.h index 3d05ae01e..94ef7b328 100644 --- a/src/include/taler_wire_plugin.h +++ b/src/include/taler_wire_plugin.h @@ -106,7 +106,8 @@ typedef int enum TALER_BANK_Direction dir, const void *row_off, size_t row_off_size, - const struct TALER_WIRE_TransferDetails *details); + const struct + TALER_WIRE_TransferDetails *details); /** @@ -201,8 +202,8 @@ struct TALER_WIRE_Plugin * @return #TALER_EC_NONE if correctly formatted */ enum TALER_ErrorCode - (*wire_validate) (void *cls, - const char *account_url); + (*wire_validate)(void *cls, + const char *account_url); /** @@ -343,7 +344,7 @@ struct TALER_WIRE_Plugin */ void (*get_history_cancel) (void *cls, - struct TALER_WIRE_HistoryHandle *whh); + struct TALER_WIRE_HistoryHandle *whh); /** diff --git a/src/json/json_helper.c b/src/json/json_helper.c index c8eab065a..b915faba0 100644 --- a/src/json/json_helper.c +++ b/src/json/json_helper.c @@ -234,7 +234,7 @@ parse_amount_nbo (void *cls, strcpy (amount.currency, currency); (void) TALER_amount_normalize (&amount); TALER_amount_hton (r_amount, - &amount); + &amount); return GNUNET_OK; } @@ -247,7 +247,7 @@ parse_amount_nbo (void *cls, */ struct GNUNET_JSON_Specification TALER_JSON_spec_amount_nbo (const char *name, - struct TALER_AmountNBO *r_amount) + struct TALER_AmountNBO *r_amount) { struct GNUNET_JSON_Specification ret = { .parser = &parse_amount_nbo, diff --git a/src/json/json_wire.c b/src/json/json_wire.c index 57a0db108..c83d52553 100644 --- a/src/json/json_wire.c +++ b/src/json/json_wire.c @@ -101,7 +101,8 @@ TALER_JSON_merchant_wire_signature_hash (const json_t *wire_s, */ int TALER_JSON_exchange_wire_signature_check (const json_t *wire_s, - const struct TALER_MasterPublicKeyP *master_pub) + const struct + TALER_MasterPublicKeyP *master_pub) { const char *payto_url; struct TALER_MasterSignatureP master_sig; @@ -143,7 +144,8 @@ TALER_JSON_exchange_wire_signature_check (const json_t *wire_s, */ json_t * TALER_JSON_exchange_wire_signature_make (const char *payto_url, - const struct TALER_MasterPrivateKeyP *master_priv) + const struct + TALER_MasterPrivateKeyP *master_priv) { struct TALER_MasterSignatureP master_sig; struct TALER_MasterPublicKeyP master_pub; diff --git a/src/json/test_json.c b/src/json/test_json.c index d5b6d13e9..5d751bf47 100644 --- a/src/json/test_json.c +++ b/src/json/test_json.c @@ -37,32 +37,32 @@ test_amount () struct TALER_Amount a2; struct GNUNET_JSON_Specification spec[] = { TALER_JSON_spec_amount ("amount", &a2), - GNUNET_JSON_spec_end() + GNUNET_JSON_spec_end () }; GNUNET_assert (GNUNET_OK == - TALER_string_to_amount ("EUR:4.3", - &a1)); - j = json_pack("{s:o}", "amount", TALER_JSON_from_amount (&a1)); + TALER_string_to_amount ("EUR:4.3", + &a1)); + j = json_pack ("{s:o}", "amount", TALER_JSON_from_amount (&a1)); GNUNET_assert (NULL != j); GNUNET_assert (GNUNET_OK == - GNUNET_JSON_parse (j, spec, + GNUNET_JSON_parse (j, spec, NULL, NULL)); GNUNET_assert (0 == - TALER_amount_cmp (&a1, - &a2)); + TALER_amount_cmp (&a1, + &a2)); json_decref (j); return 0; } int -main(int argc, - const char *const argv[]) +main (int argc, + const char *const argv[]) { GNUNET_log_setup ("test-json", - "WARNING", - NULL); + "WARNING", + NULL); if (0 != test_amount ()) return 1; return 0; diff --git a/src/json/test_json_wire.c b/src/json/test_json_wire.c index 9e59dfa8a..ad6b2342f 100644 --- a/src/json/test_json_wire.c +++ b/src/json/test_json_wire.c @@ -25,8 +25,8 @@ int -main(int argc, - const char *const argv[]) +main (int argc, + const char *const argv[]) { struct TALER_MasterPublicKeyP master_pub; struct GNUNET_CRYPTO_EddsaPrivateKey *priv; @@ -34,7 +34,7 @@ main(int argc, json_t *wire; const char *payto = "payto://x-taler-bank/42"; char *p; - + GNUNET_log_setup ("test-json-wire", "WARNING", NULL); @@ -52,7 +52,7 @@ main(int argc, TALER_JSON_exchange_wire_signature_check (wire, &master_pub)); json_decref (wire); - + return 0; } diff --git a/src/lib/auditor_api_deposit_confirmation.c b/src/lib/auditor_api_deposit_confirmation.c index 2001a2c5f..f221b7fd7 100644 --- a/src/lib/auditor_api_deposit_confirmation.c +++ b/src/lib/auditor_api_deposit_confirmation.c @@ -82,8 +82,8 @@ struct TALER_AUDITOR_DepositConfirmationHandle */ static void handle_deposit_confirmation_finished (void *cls, - long response_code, - const void *djson) + long response_code, + const void *djson) { const json_t *json = djson; struct TALER_AUDITOR_DepositConfirmationHandle *dh = cls; @@ -123,7 +123,7 @@ handle_deposit_confirmation_finished (void *cls, } dh->cb (dh->cb_cls, response_code, - TALER_JSON_get_error_code (json), + TALER_JSON_get_error_code (json), json); TALER_AUDITOR_deposit_confirmation_cancel (dh); } @@ -254,20 +254,29 @@ verify_signatures (const struct GNUNET_HashCode *h_wire, struct TALER_AUDITOR_DepositConfirmationHandle * TALER_AUDITOR_deposit_confirmation (struct TALER_AUDITOR_Handle *auditor, const struct GNUNET_HashCode *h_wire, - const struct GNUNET_HashCode *h_contract_terms, + const struct + GNUNET_HashCode *h_contract_terms, struct GNUNET_TIME_Absolute timestamp, struct GNUNET_TIME_Absolute refund_deadline, - const struct TALER_Amount *amount_without_fee, - const struct TALER_CoinSpendPublicKeyP *coin_pub, - const struct TALER_MerchantPublicKeyP *merchant_pub, - const struct TALER_ExchangePublicKeyP *exchange_pub, - const struct TALER_ExchangeSignatureP *exchange_sig, - const struct TALER_MasterPublicKeyP *master_pub, + const struct + TALER_Amount *amount_without_fee, + const struct + TALER_CoinSpendPublicKeyP *coin_pub, + const struct + TALER_MerchantPublicKeyP *merchant_pub, + const struct + TALER_ExchangePublicKeyP *exchange_pub, + const struct + TALER_ExchangeSignatureP *exchange_sig, + const struct + TALER_MasterPublicKeyP *master_pub, struct GNUNET_TIME_Absolute ep_start, struct GNUNET_TIME_Absolute ep_expire, struct GNUNET_TIME_Absolute ep_end, - const struct TALER_MasterSignatureP *master_sig, - TALER_AUDITOR_DepositConfirmationResultCallback cb, + const struct + TALER_MasterSignatureP *master_sig, + TALER_AUDITOR_DepositConfirmationResultCallback + cb, void *cb_cls) { struct TALER_AUDITOR_DepositConfirmationHandle *dh; @@ -311,10 +320,12 @@ TALER_AUDITOR_deposit_confirmation (struct TALER_AUDITOR_Handle *auditor, " s:o, s:o," /* ep_expire, ep_end */ " s:o, s:o}", /* master_sig, exchange_pub */ "h_wire", GNUNET_JSON_from_data_auto (h_wire), - "h_contract_terms", GNUNET_JSON_from_data_auto (h_contract_terms), + "h_contract_terms", GNUNET_JSON_from_data_auto ( + h_contract_terms), "timestamp", GNUNET_JSON_from_time_abs (timestamp), "refund_deadline", GNUNET_JSON_from_time_abs (refund_deadline), - "amount_without_fee", TALER_JSON_from_amount (amount_without_fee), + "amount_without_fee", TALER_JSON_from_amount ( + amount_without_fee), "coin_pub", GNUNET_JSON_from_data_auto (coin_pub), "merchant_pub", GNUNET_JSON_from_data_auto (merchant_pub), "exchange_sig", GNUNET_JSON_from_data_auto (exchange_sig), @@ -344,8 +355,8 @@ TALER_AUDITOR_deposit_confirmation (struct TALER_AUDITOR_Handle *auditor, "PUT")); if (GNUNET_OK != TALER_curl_easy_post (&dh->ctx, - eh, - deposit_confirmation_obj)) + eh, + deposit_confirmation_obj)) { GNUNET_break (0); curl_easy_cleanup (eh); @@ -375,7 +386,9 @@ TALER_AUDITOR_deposit_confirmation (struct TALER_AUDITOR_Handle *auditor, * @param deposit-confirmation the deposit-confirmation permission request handle */ void -TALER_AUDITOR_deposit_confirmation_cancel (struct TALER_AUDITOR_DepositConfirmationHandle *deposit_confirmation) +TALER_AUDITOR_deposit_confirmation_cancel (struct + TALER_AUDITOR_DepositConfirmationHandle + *deposit_confirmation) { if (NULL != deposit_confirmation->job) { diff --git a/src/lib/auditor_api_exchanges.c b/src/lib/auditor_api_exchanges.c index 770eedda3..9f37f93f7 100644 --- a/src/lib/auditor_api_exchanges.c +++ b/src/lib/auditor_api_exchanges.c @@ -118,12 +118,12 @@ handle_exchanges_finished (void *cls, int ok; ok = GNUNET_YES; - for (unsigned int i=0;iauditor = auditor; @@ -230,7 +230,8 @@ TALER_AUDITOR_list_exchanges (struct TALER_AUDITOR_Handle *auditor, * @param deposit-confirmation the deposit-confirmation permission request handle */ void -TALER_AUDITOR_list_exchanges_cancel (struct TALER_AUDITOR_ListExchangesHandle *leh) +TALER_AUDITOR_list_exchanges_cancel (struct + TALER_AUDITOR_ListExchangesHandle *leh) { if (NULL != leh->job) { diff --git a/src/lib/auditor_api_handle.c b/src/lib/auditor_api_handle.c index bf8c31abb..dfccedaa9 100644 --- a/src/lib/auditor_api_handle.c +++ b/src/lib/auditor_api_handle.c @@ -50,8 +50,8 @@ * @param code what was the curl error code */ #define CURL_STRERROR(type, function, code) \ - GNUNET_log (type, "Curl function `%s' has failed at `%s:%d' with error: %s", \ - function, __FILE__, __LINE__, curl_easy_strerror (code)); + GNUNET_log (type, "Curl function `%s' has failed at `%s:%d' with error: %s", \ + function, __FILE__, __LINE__, curl_easy_strerror (code)); /** * Stages of initialization for the `struct TALER_AUDITOR_Handle` @@ -212,10 +212,10 @@ decode_version_json (const json_t *resp_obj, const char *ver; struct GNUNET_JSON_Specification spec[] = { GNUNET_JSON_spec_string ("version", - &ver), + &ver), GNUNET_JSON_spec_fixed_auto ("auditor_public_key", - &vi->auditor_pub), - GNUNET_JSON_spec_end() + &vi->auditor_pub), + GNUNET_JSON_spec_end () }; if (JSON_OBJECT != json_typeof (resp_obj)) @@ -226,17 +226,17 @@ decode_version_json (const json_t *resp_obj, /* check the version */ if (GNUNET_OK != GNUNET_JSON_parse (resp_obj, - spec, - NULL, NULL)) + spec, + NULL, NULL)) { GNUNET_break_op (0); return GNUNET_SYSERR; } if (3 != sscanf (ver, - "%u:%u:%u", - ¤t, - &revision, - &age)) + "%u:%u:%u", + ¤t, + &revision, + &age)) { GNUNET_break_op (0); return GNUNET_SYSERR; @@ -277,8 +277,8 @@ request_version (void *cls); */ static void version_completed_cb (void *cls, - long response_code, - const void *gresp_obj) + long response_code, + const void *gresp_obj) { const json_t *resp_obj = gresp_obj; struct VersionRequest *vr = cls; @@ -331,17 +331,17 @@ version_completed_cb (void *cls, if (MHD_HTTP_OK != response_code) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "/version failed for auditor %p: %u!\n", - auditor, - (unsigned int) response_code); + "/version failed for auditor %p: %u!\n", + auditor, + (unsigned int) response_code); auditor->vr = NULL; free_version_request (vr); auditor->state = MHS_FAILED; free_version_info (&auditor->vi); /* notify application that we failed */ auditor->version_cb (auditor->version_cb_cls, - NULL, - vc); + NULL, + vc); return; } @@ -496,7 +496,7 @@ request_version (void *cls) vr = GNUNET_new (struct VersionRequest); vr->auditor = auditor; vr->url = MAH_path_to_url (auditor, - "/version"); + "/version"); GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Requesting auditor version with URL `%s'.\n", vr->url); diff --git a/src/lib/exchange_api_common.c b/src/lib/exchange_api_common.c index 7c70567df..2e13b678e 100644 --- a/src/lib/exchange_api_common.c +++ b/src/lib/exchange_api_common.c @@ -37,7 +37,8 @@ */ int TALER_EXCHANGE_verify_coin_history (const char *currency, - const struct TALER_CoinSpendPublicKeyP *coin_pub, + const struct + TALER_CoinSpendPublicKeyP *coin_pub, json_t *history, struct TALER_Amount *total) { @@ -61,7 +62,7 @@ TALER_EXCHANGE_verify_coin_history (const char *currency, GNUNET_assert (GNUNET_OK == TALER_amount_get_zero (currency, &rtotal)); - for (size_t off=0;offnum_sign_keys;i++) + for (unsigned int i = 0; inum_sign_keys; i++) { const struct TALER_EXCHANGE_SigningPublicKey *spk; diff --git a/src/lib/exchange_api_deposit.c b/src/lib/exchange_api_deposit.c index 6570a17f3..b9f535c7c 100644 --- a/src/lib/exchange_api_deposit.c +++ b/src/lib/exchange_api_deposit.c @@ -141,8 +141,10 @@ auditor_cb (void *cls, aie->dch = TALER_AUDITOR_deposit_confirmation (ah, &dh->depconf.h_wire, &dh->depconf.h_contract_terms, - GNUNET_TIME_absolute_ntoh (dh->depconf.timestamp), - GNUNET_TIME_absolute_ntoh (dh->depconf.refund_deadline), + GNUNET_TIME_absolute_ntoh ( + dh->depconf.timestamp), + GNUNET_TIME_absolute_ntoh ( + dh->depconf.refund_deadline), &amount_without_fee, &dh->depconf.coin_pub, &dh->depconf.merchant, @@ -179,7 +181,7 @@ verify_deposit_signature_ok (struct TALER_EXCHANGE_DepositHandle *dh, struct GNUNET_JSON_Specification spec[] = { GNUNET_JSON_spec_fixed_auto ("sig", exchange_sig), GNUNET_JSON_spec_fixed_auto ("pub", exchange_pub), - GNUNET_JSON_spec_end() + GNUNET_JSON_spec_end () }; if (GNUNET_OK != @@ -225,7 +227,8 @@ verify_deposit_signature_ok (struct TALER_EXCHANGE_DepositHandle *dh, * @return #GNUNET_OK if the signature(s) is valid, #GNUNET_SYSERR if not */ static int -verify_deposit_signature_forbidden (const struct TALER_EXCHANGE_DepositHandle *dh, +verify_deposit_signature_forbidden (const struct + TALER_EXCHANGE_DepositHandle *dh, const json_t *json) { json_t *history; @@ -235,9 +238,9 @@ verify_deposit_signature_forbidden (const struct TALER_EXCHANGE_DepositHandle *d "history"); if (GNUNET_OK != TALER_EXCHANGE_verify_coin_history (dh->coin_value.currency, - &dh->depconf.coin_pub, - history, - &total)) + &dh->depconf.coin_pub, + history, + &total)) { GNUNET_break_op (0); return GNUNET_SYSERR; @@ -293,7 +296,7 @@ handle_deposit_finished (void *cls, if (GNUNET_OK != verify_deposit_signature_ok (dh, j, - &exchange_sig, + &exchange_sig, &exchange_pub)) { GNUNET_break_op (0); @@ -343,8 +346,8 @@ handle_deposit_finished (void *cls, } dh->cb (dh->cb_cls, response_code, - TALER_JSON_get_error_code (j), - es, + TALER_JSON_get_error_code (j), + es, ep, j); TALER_EXCHANGE_deposit_cancel (dh); @@ -500,7 +503,7 @@ TALER_EXCHANGE_deposit (struct TALER_EXCHANGE_Handle *exchange, (void) GNUNET_TIME_round_abs (&refund_deadline); GNUNET_assert (refund_deadline.abs_value_us <= wire_deadline.abs_value_us); GNUNET_assert (GNUNET_YES == - TEAH_handle_is_ready (exchange)); + TEAH_handle_is_ready (exchange)); /* initialize h_wire */ if (GNUNET_OK != TALER_JSON_merchant_wire_signature_hash (wire_details, @@ -547,14 +550,20 @@ TALER_EXCHANGE_deposit (struct TALER_EXCHANGE_Handle *exchange, "contribution", TALER_JSON_from_amount (amount), "wire", wire_details, "H_wire", GNUNET_JSON_from_data_auto (&h_wire), - "h_contract_terms", GNUNET_JSON_from_data_auto (h_contract_terms), + "h_contract_terms", GNUNET_JSON_from_data_auto ( + h_contract_terms), "coin_pub", GNUNET_JSON_from_data_auto (coin_pub), - "denom_pub_hash", GNUNET_JSON_from_data_auto (&denom_pub_hash), - "ub_sig", GNUNET_JSON_from_rsa_signature (denom_sig->rsa_signature), + "denom_pub_hash", GNUNET_JSON_from_data_auto ( + &denom_pub_hash), + "ub_sig", GNUNET_JSON_from_rsa_signature ( + denom_sig->rsa_signature), "timestamp", GNUNET_JSON_from_time_abs (timestamp), - "merchant_pub", GNUNET_JSON_from_data_auto (merchant_pub), - "refund_deadline", GNUNET_JSON_from_time_abs (refund_deadline), - "wire_transfer_deadline", GNUNET_JSON_from_time_abs (wire_deadline), + "merchant_pub", GNUNET_JSON_from_data_auto ( + merchant_pub), + "refund_deadline", GNUNET_JSON_from_time_abs ( + refund_deadline), + "wire_transfer_deadline", GNUNET_JSON_from_time_abs ( + wire_deadline), "coin_sig", GNUNET_JSON_from_data_auto (coin_sig) ); if (NULL == deposit_obj) @@ -568,8 +577,10 @@ TALER_EXCHANGE_deposit (struct TALER_EXCHANGE_Handle *exchange, dh->cb = cb; dh->cb_cls = cb_cls; dh->url = TEAH_path_to_url (exchange, "/deposit"); - dh->depconf.purpose.size = htonl (sizeof (struct TALER_DepositConfirmationPS)); - dh->depconf.purpose.purpose = htonl (TALER_SIGNATURE_EXCHANGE_CONFIRM_DEPOSIT); + dh->depconf.purpose.size = htonl (sizeof (struct + TALER_DepositConfirmationPS)); + dh->depconf.purpose.purpose = htonl ( + TALER_SIGNATURE_EXCHANGE_CONFIRM_DEPOSIT); dh->depconf.h_contract_terms = *h_contract_terms; dh->depconf.h_wire = h_wire; dh->depconf.timestamp = GNUNET_TIME_absolute_hton (timestamp); @@ -584,8 +595,8 @@ TALER_EXCHANGE_deposit (struct TALER_EXCHANGE_Handle *exchange, eh = TEL_curl_easy_get (dh->url); if (GNUNET_OK != TALER_curl_easy_post (&dh->ctx, - eh, - deposit_obj)) + eh, + deposit_obj)) { GNUNET_break (0); curl_easy_cleanup (eh); diff --git a/src/lib/exchange_api_handle.c b/src/lib/exchange_api_handle.c index d0c0c0bad..d0777dc01 100644 --- a/src/lib/exchange_api_handle.c +++ b/src/lib/exchange_api_handle.c @@ -61,8 +61,8 @@ * @param code what was the curl error code */ #define CURL_STRERROR(type, function, code) \ - GNUNET_log (type, "Curl function `%s' has failed at `%s:%d' with error: %s", \ - function, __FILE__, __LINE__, curl_easy_strerror (code)); + GNUNET_log (type, "Curl function `%s' has failed at `%s:%d' with error: %s", \ + function, __FILE__, __LINE__, curl_easy_strerror (code)); /** * Stages of initialization for the `struct TALER_EXCHANGE_Handle` @@ -281,7 +281,8 @@ TEAH_acc_confirmation_cb (void *cls, if (MHD_HTTP_OK != http_status) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - _("Failed to submit deposit confirmation to auditor `%s' with HTTP status %d (EC: %d). This is acceptable if it does not happen often.\n"), + _ ( + "Failed to submit deposit confirmation to auditor `%s' with HTTP status %d (EC: %d). This is acceptable if it does not happen often.\n"), ale->auditor_url, http_status, (int) ec); @@ -310,7 +311,8 @@ TEAH_get_auditors_for_dc (struct TALER_EXCHANGE_Handle *h, if (NULL == h->auditors_head) { GNUNET_log (GNUNET_ERROR_TYPE_INFO, - _("No auditor available for exchange `%s'. Not submitting deposit confirmations.\n"), + _ ( + "No auditor available for exchange `%s'. Not submitting deposit confirmations.\n"), h->url); return; } @@ -385,7 +387,7 @@ parse_json_signkey (struct TALER_EXCHANGE_SigningPublicKey *sign_key, &sign_key->valid_until), GNUNET_JSON_spec_absolute_time ("stamp_end", &sign_key->valid_legal), - GNUNET_JSON_spec_end() + GNUNET_JSON_spec_end () }; if (GNUNET_OK != @@ -400,17 +402,19 @@ parse_json_signkey (struct TALER_EXCHANGE_SigningPublicKey *sign_key, if (! check_sigs) return GNUNET_OK; sign_key_issue.signkey_pub = sign_key->key; - sign_key_issue.purpose.purpose = htonl (TALER_SIGNATURE_MASTER_SIGNING_KEY_VALIDITY); - sign_key_issue.purpose.size = htonl (sizeof (struct TALER_ExchangeSigningKeyValidityPS)); + sign_key_issue.purpose.purpose = htonl ( + TALER_SIGNATURE_MASTER_SIGNING_KEY_VALIDITY); + sign_key_issue.purpose.size = htonl (sizeof (struct + TALER_ExchangeSigningKeyValidityPS)); sign_key_issue.master_public_key = *master_key; sign_key_issue.start = GNUNET_TIME_absolute_hton (sign_key->valid_from); sign_key_issue.expire = GNUNET_TIME_absolute_hton (sign_key->valid_until); sign_key_issue.end = GNUNET_TIME_absolute_hton (sign_key->valid_legal); if (GNUNET_OK != GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_MASTER_SIGNING_KEY_VALIDITY, - &sign_key_issue.purpose, - &sign_key_issue_sig.eddsa_signature, - &master_key->eddsa_pub)) + &sign_key_issue.purpose, + &sign_key_issue_sig.eddsa_signature, + &master_key->eddsa_pub)) { GNUNET_break_op (0); return GNUNET_SYSERR; @@ -462,7 +466,7 @@ parse_json_denomkey (struct TALER_EXCHANGE_DenomPublicKey *denom_key, &denom_key->fee_refund), GNUNET_JSON_spec_rsa_public_key ("denom_pub", &denom_key->key.rsa_public_key), - GNUNET_JSON_spec_end() + GNUNET_JSON_spec_end () }; if (GNUNET_OK != @@ -488,9 +492,12 @@ parse_json_denomkey (struct TALER_EXCHANGE_DenomPublicKey *denom_key, denom_key_issue.master = *master_key; denom_key_issue.denom_hash = denom_key->h_key; denom_key_issue.start = GNUNET_TIME_absolute_hton (denom_key->valid_from); - denom_key_issue.expire_withdraw = GNUNET_TIME_absolute_hton (denom_key->withdraw_valid_until); - denom_key_issue.expire_deposit = GNUNET_TIME_absolute_hton (denom_key->expire_deposit); - denom_key_issue.expire_legal = GNUNET_TIME_absolute_hton (denom_key->expire_legal); + denom_key_issue.expire_withdraw = GNUNET_TIME_absolute_hton ( + denom_key->withdraw_valid_until); + denom_key_issue.expire_deposit = GNUNET_TIME_absolute_hton ( + denom_key->expire_deposit); + denom_key_issue.expire_legal = GNUNET_TIME_absolute_hton ( + denom_key->expire_legal); TALER_amount_hton (&denom_key_issue.value, &denom_key->value); TALER_amount_hton (&denom_key_issue.fee_withdraw, @@ -502,16 +509,17 @@ parse_json_denomkey (struct TALER_EXCHANGE_DenomPublicKey *denom_key, TALER_amount_hton (&denom_key_issue.fee_refund, &denom_key->fee_refund); EXITIF (GNUNET_SYSERR == - GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_MASTER_DENOMINATION_KEY_VALIDITY, - &denom_key_issue.purpose, - &denom_key->master_sig.eddsa_signature, - &master_key->eddsa_pub)); + GNUNET_CRYPTO_eddsa_verify ( + TALER_SIGNATURE_MASTER_DENOMINATION_KEY_VALIDITY, + &denom_key_issue.purpose, + &denom_key->master_sig.eddsa_signature, + &master_key->eddsa_pub)); GNUNET_CRYPTO_hash_context_read (hash_context, &denom_key_issue.denom_hash, sizeof (struct GNUNET_HashCode)); return GNUNET_OK; - EXITIF_exit: + EXITIF_exit: GNUNET_JSON_parse_free (spec); return GNUNET_SYSERR; } @@ -547,7 +555,7 @@ parse_json_auditor (struct TALER_EXCHANGE_AuditorInformation *auditor, &auditor_url), GNUNET_JSON_spec_json ("denomination_keys", &keys), - GNUNET_JSON_spec_end() + GNUNET_JSON_spec_end () }; if (GNUNET_OK != @@ -567,7 +575,8 @@ parse_json_auditor (struct TALER_EXCHANGE_AuditorInformation *auditor, kv.master = key_data->master_pub; len = json_array_size (keys); auditor->denom_keys = GNUNET_new_array (len, - struct TALER_EXCHANGE_AuditorDenominationInfo); + struct + TALER_EXCHANGE_AuditorDenominationInfo); i = 0; off = 0; json_array_foreach (keys, i, key) { @@ -580,7 +589,7 @@ parse_json_auditor (struct TALER_EXCHANGE_AuditorInformation *auditor, &auditor_sig), GNUNET_JSON_spec_fixed_auto ("denom_pub_h", &denom_h), - GNUNET_JSON_spec_end() + GNUNET_JSON_spec_end () }; if (GNUNET_OK != @@ -593,7 +602,7 @@ parse_json_auditor (struct TALER_EXCHANGE_AuditorInformation *auditor, } dk = NULL; dk_off = UINT_MAX; - for (unsigned int j=0;jnum_denom_keys;j++) + for (unsigned int j = 0; jnum_denom_keys; j++) { if (0 == GNUNET_memcmp (&denom_h, &key_data->denom_keys[j].h_key)) @@ -617,20 +626,20 @@ parse_json_auditor (struct TALER_EXCHANGE_AuditorInformation *auditor, TALER_amount_hton (&kv.value, &dk->value); TALER_amount_hton (&kv.fee_withdraw, - &dk->fee_withdraw); + &dk->fee_withdraw); TALER_amount_hton (&kv.fee_deposit, - &dk->fee_deposit); + &dk->fee_deposit); TALER_amount_hton (&kv.fee_refresh, - &dk->fee_refresh); + &dk->fee_refresh); TALER_amount_hton (&kv.fee_refund, - &dk->fee_refund); + &dk->fee_refund); kv.denom_hash = dk->h_key; if (GNUNET_OK != - GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_AUDITOR_EXCHANGE_KEYS, - &kv.purpose, - &auditor_sig.eddsa_sig, - &auditor->auditor_pub.eddsa_pub)) + GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_AUDITOR_EXCHANGE_KEYS, + &kv.purpose, + &auditor_sig.eddsa_sig, + &auditor->auditor_pub.eddsa_pub)) { GNUNET_break_op (0); GNUNET_JSON_parse_free (spec); @@ -658,26 +667,27 @@ parse_json_auditor (struct TALER_EXCHANGE_AuditorInformation *auditor, static void auditor_version_cb (void *cls, - const struct TALER_AUDITOR_VersionInformation *vi, - enum TALER_AUDITOR_VersionCompatibility compat) + const struct TALER_AUDITOR_VersionInformation *vi, + enum TALER_AUDITOR_VersionCompatibility compat) { struct TEAH_AuditorListEntry *ale = cls; if (0 != (TALER_AUDITOR_VC_INCOMPATIBLE & compat)) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - _("Auditor `%s' runs incompatible protocol version!\n"), + _ ("Auditor `%s' runs incompatible protocol version!\n"), ale->auditor_url); if (0 != (TALER_AUDITOR_VC_OLDER & compat)) { GNUNET_log (GNUNET_ERROR_TYPE_INFO, - _("Auditor `%s' runs outdated protocol version!\n"), + _ ("Auditor `%s' runs outdated protocol version!\n"), ale->auditor_url); } if (0 != (TALER_AUDITOR_VC_NEWER & compat)) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - _("Auditor `%s' runs more recent incompatible version. We should upgrade!\n"), + _ ( + "Auditor `%s' runs more recent incompatible version. We should upgrade!\n"), ale->auditor_url); } return; @@ -698,7 +708,7 @@ update_auditors (struct TALER_EXCHANGE_Handle *exchange) struct TALER_EXCHANGE_Keys *kd = &exchange->key_data; TALER_LOG_DEBUG ("Updating auditors\n"); - for (unsigned int i=0;inum_auditors;i++) + for (unsigned int i = 0; inum_auditors; i++) { /* Compare auditor data from /keys with auditor data * from owned exchange structures. */ @@ -752,8 +762,8 @@ TALER_denoms_cmp (struct TALER_EXCHANGE_DenomPublicKey *denom1, /* First check if pub is the same. */ if (0 != GNUNET_CRYPTO_rsa_public_key_cmp - (denom1->key.rsa_public_key, - denom2->key.rsa_public_key)) + (denom1->key.rsa_public_key, + denom2->key.rsa_public_key)) return 1; tmp1 = denom1->key.rsa_public_key; @@ -815,7 +825,7 @@ decode_keys_json (const json_t *resp_obj, &key_data->list_issue_date), GNUNET_JSON_spec_relative_time ("reserve_closing_delay", &key_data->reserve_closing_delay), - GNUNET_JSON_spec_end() + GNUNET_JSON_spec_end () }; if (JSON_OBJECT != json_typeof (resp_obj)) @@ -829,7 +839,7 @@ decode_keys_json (const json_t *resp_obj, struct GNUNET_JSON_Specification spec[] = { GNUNET_JSON_spec_string ("version", &ver), - GNUNET_JSON_spec_end() + GNUNET_JSON_spec_end () }; if (GNUNET_OK != @@ -882,11 +892,11 @@ decode_keys_json (const json_t *resp_obj, unsigned int index; EXITIF (NULL == (sign_keys_array = - json_object_get (resp_obj, - "signkeys"))); + json_object_get (resp_obj, + "signkeys"))); EXITIF (JSON_ARRAY != json_typeof (sign_keys_array)); EXITIF (0 == (key_data->num_sign_keys = - json_array_size (sign_keys_array))); + json_array_size (sign_keys_array))); key_data->sign_keys = GNUNET_new_array (key_data->num_sign_keys, struct TALER_EXCHANGE_SigningPublicKey); @@ -908,8 +918,8 @@ decode_keys_json (const json_t *resp_obj, unsigned int index; EXITIF (NULL == (denom_keys_array = - json_object_get (resp_obj, - "denoms"))); + json_object_get (resp_obj, + "denoms"))); EXITIF (JSON_ARRAY != json_typeof (denom_keys_array)); index = 0; @@ -924,7 +934,7 @@ decode_keys_json (const json_t *resp_obj, &key_data->master_pub, hash_context)); - for (unsigned int j=0; + for (unsigned int j = 0; jnum_denom_keys; j++) { @@ -965,8 +975,8 @@ decode_keys_json (const json_t *resp_obj, unsigned int index; EXITIF (NULL == (auditors_array = - json_object_get (resp_obj, - "auditors"))); + json_object_get (resp_obj, + "auditors"))); EXITIF (JSON_ARRAY != json_typeof (auditors_array)); /* Merge with the existing auditor information we have (/keys cherry picking) */ @@ -983,7 +993,7 @@ decode_keys_json (const json_t *resp_obj, check_sig, auditor_info, key_data)); - for (unsigned int j=0;jnum_auditors;j++) + for (unsigned int j = 0; jnum_auditors; j++) { struct TALER_EXCHANGE_AuditorInformation *aix = &key_data->auditors[j]; @@ -998,9 +1008,10 @@ decode_keys_json (const json_t *resp_obj, aix->num_denom_keys + ai.num_denom_keys); memcpy (&aix->denom_keys[aix->num_denom_keys - ai.num_denom_keys], ai.denom_keys, - ai.num_denom_keys * sizeof (struct TALER_EXCHANGE_AuditorDenominationInfo)); - break; - } + ai.num_denom_keys * sizeof (struct + TALER_EXCHANGE_AuditorDenominationInfo)); + break; + } } if (GNUNET_YES == found) continue; /* we are done */ @@ -1025,8 +1036,8 @@ decode_keys_json (const json_t *resp_obj, &ks.hc); hash_context = NULL; EXITIF (GNUNET_OK != - TALER_EXCHANGE_test_signing_key (key_data, - &pub)); + TALER_EXCHANGE_test_signing_key (key_data, + &pub)); EXITIF (GNUNET_OK != GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_EXCHANGE_KEY_SET, &ks.purpose, @@ -1034,7 +1045,7 @@ decode_keys_json (const json_t *resp_obj, &pub.eddsa_pub)); } return GNUNET_OK; - EXITIF_exit: + EXITIF_exit: *vc = TALER_EXCHANGE_VC_PROTOCOL_ERROR; if (NULL != hash_context) @@ -1054,13 +1065,14 @@ free_key_data (struct TALER_EXCHANGE_Keys *key_data) GNUNET_array_grow (key_data->sign_keys, key_data->num_sign_keys, 0); - for (unsigned int i=0;inum_denom_keys;i++) - GNUNET_CRYPTO_rsa_public_key_free (key_data->denom_keys[i].key.rsa_public_key); + for (unsigned int i = 0; inum_denom_keys; i++) + GNUNET_CRYPTO_rsa_public_key_free ( + key_data->denom_keys[i].key.rsa_public_key); GNUNET_array_grow (key_data->denom_keys, key_data->denom_keys_size, 0); - for (unsigned int i=0;inum_auditors;i++) + for (unsigned int i = 0; inum_auditors; i++) { GNUNET_array_grow (key_data->auditors[i].denom_keys, key_data->auditors[i].num_denom_keys, @@ -1157,7 +1169,8 @@ TALER_EXCHANGE_check_keys_current (struct TALER_EXCHANGE_Handle *exchange, TEAH_handle_reset (exchange); } if ( (GNUNET_NO == force_download) && - (0 < GNUNET_TIME_absolute_get_remaining (exchange->key_data_expiration).rel_value_us) ) + (0 < GNUNET_TIME_absolute_get_remaining ( + exchange->key_data_expiration).rel_value_us) ) return exchange->key_data_expiration; if (NULL == exchange->retry_task) exchange->retry_task = GNUNET_SCHEDULER_add_now (&request_keys, @@ -1223,19 +1236,22 @@ keys_completed_cb (void *cls, /* First make a shallow copy, we then need another pass for the RSA key... */ memcpy (kd.denom_keys, kd_old.denom_keys, - kd_old.num_denom_keys * sizeof (struct TALER_EXCHANGE_DenomPublicKey)); + kd_old.num_denom_keys * sizeof (struct + TALER_EXCHANGE_DenomPublicKey)); - for (unsigned int i=0;iauditor_pub = aold->auditor_pub; @@ -1246,7 +1262,8 @@ keys_completed_cb (void *cls, aold->num_denom_keys); memcpy (anew->denom_keys, aold->denom_keys, - aold->num_denom_keys * sizeof (struct TALER_EXCHANGE_AuditorDenominationInfo)); + aold->num_denom_keys * sizeof (struct + TALER_EXCHANGE_AuditorDenominationInfo)); } /* Old auditors got just copied into new ones. */ @@ -1258,7 +1275,7 @@ keys_completed_cb (void *cls, { TALER_LOG_ERROR ("Could not decode /keys response\n"); response_code = 0; - for (unsigned int i=0;iurl, - path); + path); } @@ -1391,7 +1408,7 @@ TEAH_path_to_url (struct TALER_EXCHANGE_Handle *h, */ char * TEAH_path_to_url2 (const char *base_url, - const char *path) + const char *path) { char *url; @@ -1515,14 +1532,14 @@ deserialize_data (struct TALER_EXCHANGE_Handle *exchange, struct GNUNET_TIME_Absolute expire; struct GNUNET_JSON_Specification spec[] = { GNUNET_JSON_spec_uint32 ("version", - &version), + &version), GNUNET_JSON_spec_json ("keys", - &keys), + &keys), GNUNET_JSON_spec_string ("url", - &url), + &url), GNUNET_JSON_spec_absolute_time ("expire", &expire), - GNUNET_JSON_spec_end() + GNUNET_JSON_spec_end () }; struct TALER_EXCHANGE_Keys key_data; @@ -1539,23 +1556,23 @@ deserialize_data (struct TALER_EXCHANGE_Handle *exchange, if (0 != version) return; /* unsupported version */ if (0 != strcmp (url, - exchange->url)) + exchange->url)) { GNUNET_break (0); return; } memset (&key_data, - 0, + 0, sizeof (struct TALER_EXCHANGE_Keys)); if (GNUNET_OK != decode_keys_json (keys, GNUNET_NO, &key_data, &vc)) - { - GNUNET_break (0); - return; - } + { + GNUNET_break (0); + return; + } /* decode successful, initialize with the result */ GNUNET_assert (NULL == exchange->key_data_raw); exchange->key_data_raw = json_deep_copy (keys); @@ -1566,7 +1583,7 @@ deserialize_data (struct TALER_EXCHANGE_Handle *exchange, /* notify application about the key information */ exchange->cert_cb (exchange->cert_cb_cls, &exchange->key_data, - vc); + vc); } @@ -1599,7 +1616,7 @@ TALER_EXCHANGE_serialize_data GNUNET_break (0); return NULL; } - for (unsigned int i=0;inum_sign_keys;i++) + for (unsigned int i = 0; inum_sign_keys; i++) { const struct TALER_EXCHANGE_SigningPublicKey *sk = &kd->sign_keys[i]; json_t *signkey; @@ -1609,19 +1626,19 @@ TALER_EXCHANGE_serialize_data signkey = json_pack ("{s:o, s:o, s:o, s:o, s:o}", "key", GNUNET_JSON_from_data_auto - (&sk->key), + (&sk->key), "master_sig", GNUNET_JSON_from_data_auto - (&sk->master_sig), + (&sk->master_sig), "stamp_start", GNUNET_JSON_from_time_abs - (sk->valid_from), + (sk->valid_from), "stamp_expire", GNUNET_JSON_from_time_abs - (sk->valid_until), + (sk->valid_until), "stamp_end", GNUNET_JSON_from_time_abs - (sk->valid_legal)); + (sk->valid_legal)); if (NULL == signkey) { GNUNET_break (0); @@ -1643,7 +1660,7 @@ TALER_EXCHANGE_serialize_data json_decref (signkeys); return NULL; } - for (unsigned int i=0;inum_denom_keys;i++) + for (unsigned int i = 0; inum_denom_keys; i++) { const struct TALER_EXCHANGE_DenomPublicKey *dk = &kd->denom_keys[i]; json_t *denom; @@ -1676,14 +1693,15 @@ TALER_EXCHANGE_serialize_data GNUNET_JSON_from_data_auto (&dk->master_sig), /* #10 */ "denom_pub", - GNUNET_JSON_from_rsa_public_key (dk->key.rsa_public_key)); + GNUNET_JSON_from_rsa_public_key ( + dk->key.rsa_public_key)); if (NULL == denom) { GNUNET_break (0); continue; } if (0 != json_array_append_new (denoms, - denom)) + denom)) { GNUNET_break (0); json_decref (denom); @@ -1700,7 +1718,7 @@ TALER_EXCHANGE_serialize_data json_decref (signkeys); return NULL; } - for (unsigned int i=0;inum_auditors;i++) + for (unsigned int i = 0; inum_auditors; i++) { const struct TALER_EXCHANGE_AuditorInformation *ai = &kd->auditors[i]; json_t *a; @@ -1715,10 +1733,12 @@ TALER_EXCHANGE_serialize_data json_decref (auditors); return NULL; } - for (unsigned int j=0;jnum_denom_keys;j++) + for (unsigned int j = 0; jnum_denom_keys; j++) { - const struct TALER_EXCHANGE_AuditorDenominationInfo *adi = &ai->denom_keys[j]; - const struct TALER_EXCHANGE_DenomPublicKey *dk = &kd->denom_keys[adi->denom_key_offset]; + const struct TALER_EXCHANGE_AuditorDenominationInfo *adi = + &ai->denom_keys[j]; + const struct TALER_EXCHANGE_DenomPublicKey *dk = + &kd->denom_keys[adi->denom_key_offset]; json_t *k; if (now.abs_value_us > dk->expire_deposit.abs_value_us) @@ -1832,10 +1852,10 @@ TALER_EXCHANGE_serialize_data struct TALER_EXCHANGE_Handle * TALER_EXCHANGE_connect (struct GNUNET_CURL_Context *ctx, - const char *url, - TALER_EXCHANGE_CertificationCallback cert_cb, - void *cert_cb_cls, - ...) + const char *url, + TALER_EXCHANGE_CertificationCallback cert_cb, + void *cert_cb_cls, + ...) { struct TALER_EXCHANGE_Handle *exchange; va_list ap; @@ -1845,8 +1865,8 @@ TALER_EXCHANGE_connect url); /* Disable 100 continue processing */ GNUNET_break (GNUNET_OK == - GNUNET_CURL_append_header (ctx, - "Expect:")); + GNUNET_CURL_append_header (ctx, + "Expect:")); exchange = GNUNET_new (struct TALER_EXCHANGE_Handle); exchange->ctx = ctx; exchange->url = GNUNET_strdup (url); @@ -1856,20 +1876,21 @@ TALER_EXCHANGE_connect exchange); va_start (ap, cert_cb_cls); while (TALER_EXCHANGE_OPTION_END != - (opt = va_arg (ap, int))) + (opt = va_arg (ap, int))) { - switch (opt) { + switch (opt) + { case TALER_EXCHANGE_OPTION_END: GNUNET_assert (0); break; case TALER_EXCHANGE_OPTION_DATA: - { - const json_t *data = va_arg (ap, const json_t *); + { + const json_t *data = va_arg (ap, const json_t *); - deserialize_data (exchange, - data); - break; - } + deserialize_data (exchange, + data); + break; + } default: GNUNET_assert (0); break; @@ -1902,10 +1923,13 @@ request_keys (void *cls) if (GNUNET_YES == TEAH_handle_is_ready (exchange)) { TALER_LOG_DEBUG ("Last DK issue date (before GETting /keys): %s\n", - GNUNET_STRINGS_absolute_time_to_string (exchange->key_data.last_denom_issue_date)); + GNUNET_STRINGS_absolute_time_to_string ( + exchange->key_data.last_denom_issue_date)); sprintf (&url[strlen (url)], "last_issue_date=%llu&", - (unsigned long long) exchange->key_data.last_denom_issue_date.abs_value_us / 1000000LLU); + (unsigned long + long) exchange->key_data.last_denom_issue_date.abs_value_us + / 1000000LLU); } if (GNUNET_YES == exchange->with_now) @@ -1969,7 +1993,8 @@ TALER_EXCHANGE_disconnect (struct TALER_EXCHANGE_Handle *exchange) { GNUNET_assert (aie->ale == ale); GNUNET_log (GNUNET_ERROR_TYPE_INFO, - _("Not sending deposit confirmation to auditor `%s' due to exchange disconnect\n"), + _ ( + "Not sending deposit confirmation to auditor `%s' due to exchange disconnect\n"), ale->auditor_url); TALER_AUDITOR_deposit_confirmation_cancel (aie->dch); GNUNET_CONTAINER_DLL_remove (ale->ai_head, @@ -2017,9 +2042,10 @@ TALER_EXCHANGE_disconnect (struct TALER_EXCHANGE_Handle *exchange) */ const struct TALER_EXCHANGE_SigningPublicKey * TALER_EXCHANGE_get_signing_key_details (const struct TALER_EXCHANGE_Keys *keys, - const struct TALER_ExchangePublicKeyP *pub) + const struct + TALER_ExchangePublicKeyP *pub) { - for (unsigned int i=0;inum_sign_keys;i++) + for (unsigned int i = 0; inum_sign_keys; i++) { struct TALER_EXCHANGE_SigningPublicKey *spk = &keys->sign_keys[i]; @@ -2047,9 +2073,11 @@ TALER_EXCHANGE_test_signing_key (const struct TALER_EXCHANGE_Keys *keys, /* we will check using a tolerance of 1h for the time */ now = GNUNET_TIME_absolute_get (); - for (unsigned int i=0;inum_sign_keys;i++) - if ( (keys->sign_keys[i].valid_from.abs_value_us <= now.abs_value_us + 60 * 60 * 1000LL * 1000LL) && - (keys->sign_keys[i].valid_until.abs_value_us > now.abs_value_us - 60 * 60 * 1000LL * 1000LL) && + for (unsigned int i = 0; inum_sign_keys; i++) + if ( (keys->sign_keys[i].valid_from.abs_value_us <= now.abs_value_us + 60 + * 60 * 1000LL * 1000LL) && + (keys->sign_keys[i].valid_until.abs_value_us > now.abs_value_us - 60 + * 60 * 1000LL * 1000LL) && (0 == GNUNET_memcmp (pub, &keys->sign_keys[i].key)) ) return GNUNET_OK; @@ -2080,11 +2108,13 @@ TALER_EXCHANGE_get_base_url (const struct TALER_EXCHANGE_Handle *exchange) */ const struct TALER_EXCHANGE_DenomPublicKey * TALER_EXCHANGE_get_denomination_key (const struct TALER_EXCHANGE_Keys *keys, - const struct TALER_DenominationPublicKey *pk) + const struct + TALER_DenominationPublicKey *pk) { - for (unsigned int i=0;inum_denom_keys;i++) + for (unsigned int i = 0; inum_denom_keys; i++) if (0 == GNUNET_CRYPTO_rsa_public_key_cmp (pk->rsa_public_key, - keys->denom_keys[i].key.rsa_public_key)) + keys->denom_keys[i].key. + rsa_public_key)) return &keys->denom_keys[i]; return NULL; } @@ -2098,10 +2128,11 @@ TALER_EXCHANGE_get_denomination_key (const struct TALER_EXCHANGE_Keys *keys, * @return details about the given denomination key */ const struct TALER_EXCHANGE_DenomPublicKey * -TALER_EXCHANGE_get_denomination_key_by_hash (const struct TALER_EXCHANGE_Keys *keys, +TALER_EXCHANGE_get_denomination_key_by_hash (const struct + TALER_EXCHANGE_Keys *keys, const struct GNUNET_HashCode *hc) { - for (unsigned int i=0;inum_denom_keys;i++) + for (unsigned int i = 0; inum_denom_keys; i++) if (0 == GNUNET_memcmp (hc, &keys->denom_keys[i].h_key)) return &keys->denom_keys[i]; diff --git a/src/lib/exchange_api_handle.h b/src/lib/exchange_api_handle.h index 81e6d7c5e..a88cb70de 100644 --- a/src/lib/exchange_api_handle.h +++ b/src/lib/exchange_api_handle.h @@ -70,8 +70,8 @@ struct TEAH_AuditorInteractionEntry */ typedef struct TEAH_AuditorInteractionEntry * (*TEAH_AuditorCallback)(void *cls, - struct TALER_AUDITOR_Handle *ah, - const struct TALER_AuditorPublicKeyP *auditor_pub); + struct TALER_AUDITOR_Handle *ah, + const struct TALER_AuditorPublicKeyP *auditor_pub); /** @@ -101,8 +101,8 @@ TEAH_acc_confirmation_cb (void *cls, */ void TEAH_get_auditors_for_dc (struct TALER_EXCHANGE_Handle *h, - TEAH_AuditorCallback ac, - void *ac_cls); + TEAH_AuditorCallback ac, + void *ac_cls); /** @@ -134,7 +134,7 @@ TEAH_handle_is_ready (struct TALER_EXCHANGE_Handle *h); */ char * TEAH_path_to_url (struct TALER_EXCHANGE_Handle *h, - const char *path); + const char *path); /** @@ -146,7 +146,7 @@ TEAH_path_to_url (struct TALER_EXCHANGE_Handle *h, */ char * TEAH_path_to_url2 (const char *base_url, - const char *path); + const char *path); /* end of exchange_api_handle.h */ diff --git a/src/lib/exchange_api_payback.c b/src/lib/exchange_api_payback.c index 64dfa3796..912548cfe 100644 --- a/src/lib/exchange_api_payback.c +++ b/src/lib/exchange_api_payback.c @@ -114,7 +114,7 @@ verify_payback_signature_ok (const struct TALER_EXCHANGE_PaybackHandle *ph, TALER_JSON_spec_amount ("amount", &amount), GNUNET_JSON_spec_absolute_time ("timestamp", ×tamp), GNUNET_JSON_spec_fixed_auto ("reserve_pub", &pc.reserve_pub), - GNUNET_JSON_spec_end() + GNUNET_JSON_spec_end () }; struct GNUNET_JSON_Specification spec_refresh[] = { GNUNET_JSON_spec_fixed_auto ("exchange_sig", &exchange_sig), @@ -122,7 +122,7 @@ verify_payback_signature_ok (const struct TALER_EXCHANGE_PaybackHandle *ph, TALER_JSON_spec_amount ("amount", &amount), GNUNET_JSON_spec_absolute_time ("timestamp", ×tamp), GNUNET_JSON_spec_fixed_auto ("old_coin_pub", &pr.old_coin_pub), - GNUNET_JSON_spec_end() + GNUNET_JSON_spec_end () }; if (GNUNET_OK != @@ -143,17 +143,19 @@ verify_payback_signature_ok (const struct TALER_EXCHANGE_PaybackHandle *ph, } if (ph->was_refreshed) { - pr.purpose.purpose = htonl (TALER_SIGNATURE_EXCHANGE_CONFIRM_PAYBACK_REFRESH); + pr.purpose.purpose = htonl ( + TALER_SIGNATURE_EXCHANGE_CONFIRM_PAYBACK_REFRESH); pr.purpose.size = htonl (sizeof (pr)); pr.timestamp = GNUNET_TIME_absolute_hton (timestamp); TALER_amount_hton (&pr.payback_amount, &amount); pr.coin_pub = ph->coin_pub; if (GNUNET_OK != - GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_EXCHANGE_CONFIRM_PAYBACK_REFRESH, - &pr.purpose, - &exchange_sig.eddsa_signature, - &exchange_pub.eddsa_pub)) + GNUNET_CRYPTO_eddsa_verify ( + TALER_SIGNATURE_EXCHANGE_CONFIRM_PAYBACK_REFRESH, + &pr.purpose, + &exchange_sig.eddsa_signature, + &exchange_pub.eddsa_pub)) { GNUNET_break_op (0); return GNUNET_SYSERR; @@ -233,12 +235,12 @@ handle_payback_finished (void *cls, dki = &ph->pk; history = json_object_get (j, - "history"); + "history"); if (GNUNET_OK != - TALER_EXCHANGE_verify_coin_history (dki->fee_deposit.currency, - &ph->coin_pub, - history, - &total)) + TALER_EXCHANGE_verify_coin_history (dki->fee_deposit.currency, + &ph->coin_pub, + history, + &total)) { GNUNET_break_op (0); response_code = 0; @@ -326,7 +328,7 @@ TALER_EXCHANGE_payback (struct TALER_EXCHANGE_Handle *exchange, CURL *eh; GNUNET_assert (GNUNET_YES == - TEAH_handle_is_ready (exchange)); + TEAH_handle_is_ready (exchange)); pr.purpose.purpose = htonl (TALER_SIGNATURE_WALLET_COIN_PAYBACK); pr.purpose.size = htonl (sizeof (struct TALER_PaybackRequestPS)); GNUNET_CRYPTO_eddsa_key_get_public (&ps->coin_priv.eddsa_priv, @@ -343,13 +345,17 @@ TALER_EXCHANGE_payback (struct TALER_EXCHANGE_Handle *exchange, payback_obj = json_pack ("{s:o, s:o," /* denom pub/sig */ " s:o, s:o," /* coin pub/sig */ " s:o, s:o}", /* coin_bks */ - "denom_pub_hash", GNUNET_JSON_from_data_auto (&h_denom_pub), - "denom_sig", GNUNET_JSON_from_rsa_signature (denom_sig->rsa_signature), - "coin_pub", GNUNET_JSON_from_data_auto (&pr.coin_pub), + "denom_pub_hash", GNUNET_JSON_from_data_auto ( + &h_denom_pub), + "denom_sig", GNUNET_JSON_from_rsa_signature ( + denom_sig->rsa_signature), + "coin_pub", GNUNET_JSON_from_data_auto ( + &pr.coin_pub), "coin_sig", GNUNET_JSON_from_data_auto (&coin_sig), - "coin_blind_key_secret", GNUNET_JSON_from_data_auto (&ps->blinding_key), + "coin_blind_key_secret", GNUNET_JSON_from_data_auto ( + &ps->blinding_key), "refreshed", json_boolean (was_refreshed) - ); + ); if (NULL == payback_obj) { GNUNET_break (0); @@ -360,7 +366,8 @@ TALER_EXCHANGE_payback (struct TALER_EXCHANGE_Handle *exchange, ph->coin_pub = pr.coin_pub; ph->exchange = exchange; ph->pk = *pk; - ph->pk.key.rsa_public_key = GNUNET_CRYPTO_rsa_public_key_dup (pk->key.rsa_public_key); + ph->pk.key.rsa_public_key = GNUNET_CRYPTO_rsa_public_key_dup ( + pk->key.rsa_public_key); ph->cb = payback_cb; ph->cb_cls = payback_cb_cls; ph->url = TEAH_path_to_url (exchange, "/payback"); @@ -368,8 +375,8 @@ TALER_EXCHANGE_payback (struct TALER_EXCHANGE_Handle *exchange, eh = TEL_curl_easy_get (ph->url); if (GNUNET_OK != TALER_curl_easy_post (&ph->ctx, - eh, - payback_obj)) + eh, + payback_obj)) { GNUNET_break (0); curl_easy_cleanup (eh); @@ -385,10 +392,10 @@ TALER_EXCHANGE_payback (struct TALER_EXCHANGE_Handle *exchange, ph->url); ctx = TEAH_handle_to_context (exchange); ph->job = GNUNET_CURL_job_add2 (ctx, - eh, - ph->ctx.headers, - &handle_payback_finished, - ph); + eh, + ph->ctx.headers, + &handle_payback_finished, + ph); return ph; } diff --git a/src/lib/exchange_api_refresh.c b/src/lib/exchange_api_refresh.c index 617eab393..f99f3ab02 100644 --- a/src/lib/exchange_api_refresh.c +++ b/src/lib/exchange_api_refresh.c @@ -239,13 +239,13 @@ free_melt_data (struct MeltData *md) free_melted_coin (&md->melted_coin); if (NULL != md->fresh_pks) { - for (unsigned int i=0;inum_fresh_coins;i++) + for (unsigned int i = 0; inum_fresh_coins; i++) if (NULL != md->fresh_pks[i].rsa_public_key) GNUNET_CRYPTO_rsa_public_key_free (md->fresh_pks[i].rsa_public_key); GNUNET_free (md->fresh_pks); } - for (unsigned int i=0;ifresh_coins[i]); /* Finally, clean up a bit... (NOTE: compilers might optimize this away, so this is @@ -302,7 +302,7 @@ serialize_melted_coin (const struct MeltedCoin *mc, &mc->fee_melt); TALER_amount_hton (&mcp.original_value, &mc->original_value); - for (i=0;itransfer_priv[i]; mcp.expire_deposit = GNUNET_TIME_absolute_hton (mc->expire_deposit); mcp.pbuf_size = htons ((uint16_t) pbuf_size); @@ -384,7 +384,7 @@ deserialize_melted_coin (struct MeltedCoin *mc, &mcp.fee_melt); TALER_amount_ntoh (&mc->original_value, &mcp.original_value); - for (i=0;itransfer_priv[i] = mcp.transfer_priv[i]; mc->expire_deposit = GNUNET_TIME_absolute_ntoh (mcp.expire_deposit); return off; @@ -493,8 +493,8 @@ serialize_fresh_coin (const struct TALER_PlanchetSecretsP *fc, { if (NULL != buf) memcpy (&buf[off], - fc, - sizeof (struct TALER_PlanchetSecretsP)); + fc, + sizeof (struct TALER_PlanchetSecretsP)); return sizeof (struct TALER_PlanchetSecretsP); } @@ -566,12 +566,12 @@ serialize_melt_data (const struct MeltData *md, size += serialize_melted_coin (&md->melted_coin, buf, size); - for (unsigned int i=0;inum_fresh_coins;i++) + for (unsigned int i = 0; inum_fresh_coins; i++) size += serialize_denomination_key (&md->fresh_pks[i], buf, size); - for (unsigned int i=0;inum_fresh_coins;j++) + for (unsigned int i = 0; inum_fresh_coins; j++) size += serialize_fresh_coin (&md->fresh_coins[i][j], buf, size); @@ -608,7 +608,7 @@ deserialize_melt_data (const char *buf, md->num_fresh_coins = ntohs (mdp.num_fresh_coins); md->fresh_pks = GNUNET_new_array (md->num_fresh_coins, struct TALER_DenominationPublicKey); - for (unsigned int i=0;ifresh_coins[i] = GNUNET_new_array (md->num_fresh_coins, struct TALER_PlanchetSecretsP); off = sizeof (struct MeltDataP); @@ -617,14 +617,14 @@ deserialize_melt_data (const char *buf, &buf[off], buf_size - off, &ok); - for (unsigned int i=0;(inum_fresh_coins)&&(GNUNET_YES == ok);i++) + for (unsigned int i = 0; (inum_fresh_coins)&&(GNUNET_YES == ok); i++) off += deserialize_denomination_key (&md->fresh_pks[i], &buf[off], buf_size - off, &ok); - for (unsigned int i=0;inum_fresh_coins)&&(GNUNET_YES == ok);j++) + for (unsigned int i = 0; inum_fresh_coins)&&(GNUNET_YES == ok); j++) off += deserialize_fresh_coin (&md->fresh_coins[i][j], &buf[off], buf_size - off, @@ -686,13 +686,17 @@ deserialize_melt_data (const char *buf, * Non-null results should be freed using GNUNET_free(). */ char * -TALER_EXCHANGE_refresh_prepare (const struct TALER_CoinSpendPrivateKeyP *melt_priv, +TALER_EXCHANGE_refresh_prepare (const struct + TALER_CoinSpendPrivateKeyP *melt_priv, const struct TALER_Amount *melt_amount, - const struct TALER_DenominationSignature *melt_sig, - const struct TALER_EXCHANGE_DenomPublicKey *melt_pk, + const struct + TALER_DenominationSignature *melt_sig, + const struct + TALER_EXCHANGE_DenomPublicKey *melt_pk, int check_sig, unsigned int fresh_pks_len, - const struct TALER_EXCHANGE_DenomPublicKey *fresh_pks, + const struct + TALER_EXCHANGE_DenomPublicKey *fresh_pks, size_t *res_size) { struct MeltData md; @@ -722,7 +726,7 @@ TALER_EXCHANGE_refresh_prepare (const struct TALER_CoinSpendPrivateKeyP *melt_pr = GNUNET_CRYPTO_rsa_signature_dup (melt_sig->rsa_signature); md.fresh_pks = GNUNET_new_array (fresh_pks_len, struct TALER_DenominationPublicKey); - for (unsigned int i=0;imd->rc; confirm.noreveal_index = htonl (*noreveal_index); if (GNUNET_OK != @@ -941,7 +947,8 @@ verify_refresh_melt_signature_ok (struct TALER_EXCHANGE_RefreshMeltHandle *rmh, * @return #GNUNET_OK if the signature(s) is valid, #GNUNET_SYSERR if not */ static int -verify_refresh_melt_signature_forbidden (struct TALER_EXCHANGE_RefreshMeltHandle *rmh, +verify_refresh_melt_signature_forbidden (struct + TALER_EXCHANGE_RefreshMeltHandle *rmh, const json_t *json) { json_t *history; @@ -954,7 +961,7 @@ verify_refresh_melt_signature_forbidden (struct TALER_EXCHANGE_RefreshMeltHandle GNUNET_JSON_spec_fixed_auto ("coin_pub", &coin_pub), TALER_JSON_spec_amount ("original_value", &original_value), TALER_JSON_spec_amount ("requested_value", &melt_value_with_fee), - GNUNET_JSON_spec_end() + GNUNET_JSON_spec_end () }; const struct MeltedCoin *mc; @@ -994,9 +1001,9 @@ verify_refresh_melt_signature_forbidden (struct TALER_EXCHANGE_RefreshMeltHandle "history"); if (GNUNET_OK != TALER_EXCHANGE_verify_coin_history (original_value.currency, - &coin_pub, - history, - &total)) + &coin_pub, + history, + &total)) { GNUNET_break_op (0); json_decref (history); @@ -1111,7 +1118,7 @@ handle_refresh_melt_finished (void *cls, if (NULL != rmh->melt_cb) rmh->melt_cb (rmh->melt_cb_cls, response_code, - TALER_JSON_get_error_code (j), + TALER_JSON_get_error_code (j), UINT32_MAX, NULL, j); @@ -1156,7 +1163,7 @@ TALER_EXCHANGE_refresh_melt (struct TALER_EXCHANGE_Handle *exchange, struct GNUNET_HashCode h_denom_pub; GNUNET_assert (GNUNET_YES == - TEAH_handle_is_ready (exchange)); + TEAH_handle_is_ready (exchange)); md = deserialize_melt_data (refresh_data, refresh_data_length); if (NULL == md) @@ -1166,7 +1173,8 @@ TALER_EXCHANGE_refresh_melt (struct TALER_EXCHANGE_Handle *exchange, } melt.purpose.purpose = htonl (TALER_SIGNATURE_WALLET_COIN_MELT); - melt.purpose.size = htonl (sizeof (struct TALER_RefreshMeltCoinAffirmationPS)); + melt.purpose.size = htonl (sizeof (struct + TALER_RefreshMeltCoinAffirmationPS)); melt.rc = md->rc; TALER_amount_hton (&melt.amount_with_fee, &md->melted_coin.melt_amount_with_fee); @@ -1185,11 +1193,13 @@ TALER_EXCHANGE_refresh_melt (struct TALER_EXCHANGE_Handle *exchange, "denom_pub_hash", GNUNET_JSON_from_data_auto (&h_denom_pub), "denom_sig", - GNUNET_JSON_from_rsa_signature (md->melted_coin.sig.rsa_signature), + GNUNET_JSON_from_rsa_signature ( + md->melted_coin.sig.rsa_signature), "confirm_sig", GNUNET_JSON_from_data_auto (&confirm_sig), "value_with_fee", - TALER_JSON_from_amount (&md->melted_coin.melt_amount_with_fee), + TALER_JSON_from_amount ( + &md->melted_coin.melt_amount_with_fee), "rc", GNUNET_JSON_from_data_auto (&melt.rc)); if (NULL == melt_obj) @@ -1206,12 +1216,12 @@ TALER_EXCHANGE_refresh_melt (struct TALER_EXCHANGE_Handle *exchange, rmh->melt_cb_cls = melt_cb_cls; rmh->md = md; rmh->url = TEAH_path_to_url (exchange, - "/refresh/melt"); + "/refresh/melt"); eh = TEL_curl_easy_get (rmh->url); if (GNUNET_OK != TALER_curl_easy_post (&rmh->ctx, - eh, - melt_obj)) + eh, + melt_obj)) { GNUNET_break (0); curl_easy_cleanup (eh); @@ -1238,7 +1248,8 @@ TALER_EXCHANGE_refresh_melt (struct TALER_EXCHANGE_Handle *exchange, * @param rmh the refresh melt handle */ void -TALER_EXCHANGE_refresh_melt_cancel (struct TALER_EXCHANGE_RefreshMeltHandle *rmh) +TALER_EXCHANGE_refresh_melt_cancel (struct + TALER_EXCHANGE_RefreshMeltHandle *rmh) { if (NULL != rmh->job) { @@ -1329,7 +1340,7 @@ refresh_reveal_ok (struct TALER_EXCHANGE_RefreshRevealHandle *rrh, json_t *jsona; struct GNUNET_JSON_Specification outer_spec[] = { GNUNET_JSON_spec_json ("ev_sigs", &jsona), - GNUNET_JSON_spec_end() + GNUNET_JSON_spec_end () }; if (GNUNET_OK != @@ -1354,7 +1365,7 @@ refresh_reveal_ok (struct TALER_EXCHANGE_RefreshRevealHandle *rrh, GNUNET_JSON_parse_free (outer_spec); return GNUNET_SYSERR; } - for (unsigned int i=0;imd->num_fresh_coins;i++) + for (unsigned int i = 0; imd->num_fresh_coins; i++) { const struct TALER_PlanchetSecretsP *fc; struct TALER_DenominationPublicKey *pk; @@ -1364,7 +1375,7 @@ refresh_reveal_ok (struct TALER_EXCHANGE_RefreshRevealHandle *rrh, struct GNUNET_HashCode coin_hash; struct GNUNET_JSON_Specification spec[] = { GNUNET_JSON_spec_rsa_signature ("ev_sig", &blind_sig), - GNUNET_JSON_spec_end() + GNUNET_JSON_spec_end () }; struct TALER_FreshCoin coin; @@ -1455,7 +1466,7 @@ handle_refresh_reveal_finished (void *cls, j); rrh->reveal_cb = NULL; } - for (unsigned int i=0;imd->num_fresh_coins;i++) + for (unsigned int i = 0; imd->num_fresh_coins; i++) if (NULL != sigs[i].rsa_signature) GNUNET_CRYPTO_rsa_signature_free (sigs[i].rsa_signature); } @@ -1559,14 +1570,15 @@ TALER_EXCHANGE_refresh_reveal (struct TALER_EXCHANGE_Handle *exchange, } /* now transfer_pub */ - GNUNET_CRYPTO_ecdhe_key_get_public (&md->melted_coin.transfer_priv[noreveal_index].ecdhe_priv, - &transfer_pub.ecdhe_pub); + GNUNET_CRYPTO_ecdhe_key_get_public ( + &md->melted_coin.transfer_priv[noreveal_index].ecdhe_priv, + &transfer_pub.ecdhe_pub); /* now new_denoms */ GNUNET_assert (NULL != (new_denoms_h = json_array ())); GNUNET_assert (NULL != (coin_evs = json_array ())); GNUNET_assert (NULL != (link_sigs = json_array ())); - for (unsigned int i=0;inum_fresh_coins;i++) + for (unsigned int i = 0; inum_fresh_coins; i++) { struct GNUNET_HashCode denom_hash; struct TALER_PlanchetDetail pd; @@ -1575,7 +1587,8 @@ TALER_EXCHANGE_refresh_reveal (struct TALER_EXCHANGE_Handle *exchange, &denom_hash); GNUNET_assert (0 == json_array_append_new (new_denoms_h, - GNUNET_JSON_from_data_auto (&denom_hash))); + GNUNET_JSON_from_data_auto ( + &denom_hash))); if (GNUNET_OK != TALER_planchet_prepare (&md->fresh_pks[i], @@ -1608,12 +1621,14 @@ TALER_EXCHANGE_refresh_reveal (struct TALER_EXCHANGE_Handle *exchange, pd.coin_ev_size, &ldp.coin_envelope_hash); GNUNET_assert (GNUNET_OK == - GNUNET_CRYPTO_eddsa_sign (&md->melted_coin.coin_priv.eddsa_priv, - &ldp.purpose, - &link_sig.eddsa_signature)); + GNUNET_CRYPTO_eddsa_sign ( + &md->melted_coin.coin_priv.eddsa_priv, + &ldp.purpose, + &link_sig.eddsa_signature)); GNUNET_assert (0 == json_array_append_new (link_sigs, - GNUNET_JSON_from_data_auto (&link_sig))); + GNUNET_JSON_from_data_auto ( + &link_sig))); } GNUNET_free (pd.coin_ev); @@ -1621,17 +1636,18 @@ TALER_EXCHANGE_refresh_reveal (struct TALER_EXCHANGE_Handle *exchange, /* build array of transfer private keys */ GNUNET_assert (NULL != (transfer_privs = json_array ())); - for (unsigned int j=0;jmelted_coin.transfer_priv[j]))); + GNUNET_JSON_from_data_auto ( + &md->melted_coin.transfer_priv[j]))); } /* build main JSON request */ @@ -1662,13 +1678,13 @@ TALER_EXCHANGE_refresh_reveal (struct TALER_EXCHANGE_Handle *exchange, rrh->reveal_cb_cls = reveal_cb_cls; rrh->md = md; rrh->url = TEAH_path_to_url (rrh->exchange, - "/refresh/reveal"); + "/refresh/reveal"); eh = TEL_curl_easy_get (rrh->url); if (GNUNET_OK != TALER_curl_easy_post (&rrh->ctx, - eh, - reveal_obj)) + eh, + reveal_obj)) { GNUNET_break (0); curl_easy_cleanup (eh); @@ -1695,7 +1711,8 @@ TALER_EXCHANGE_refresh_reveal (struct TALER_EXCHANGE_Handle *exchange, * @param rrh the refresh reval handle */ void -TALER_EXCHANGE_refresh_reveal_cancel (struct TALER_EXCHANGE_RefreshRevealHandle *rrh) +TALER_EXCHANGE_refresh_reveal_cancel (struct + TALER_EXCHANGE_RefreshRevealHandle *rrh) { if (NULL != rrh->job) { diff --git a/src/lib/exchange_api_refresh_link.c b/src/lib/exchange_api_refresh_link.c index 02b9f2387..2369b90b3 100644 --- a/src/lib/exchange_api_refresh_link.c +++ b/src/lib/exchange_api_refresh_link.c @@ -98,7 +98,7 @@ parse_refresh_link_coin (const struct TALER_EXCHANGE_RefreshLinkHandle *rlh, GNUNET_JSON_spec_rsa_public_key ("denom_pub", &rpub), GNUNET_JSON_spec_rsa_signature ("ev_sig", &bsig), GNUNET_JSON_spec_fixed_auto ("link_sig", &link_sig), - GNUNET_JSON_spec_end() + GNUNET_JSON_spec_end () }; struct TALER_TransferSecretP secret; struct TALER_PlanchetSecretsP fc; @@ -151,7 +151,7 @@ parse_refresh_link_coin (const struct TALER_EXCHANGE_RefreshLinkHandle *rlh, pd.coin_ev_size, &ldp.coin_envelope_hash); GNUNET_free (pd.coin_ev); - + if (GNUNET_OK != GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_WALLET_COIN_LINK, &ldp.purpose, @@ -163,7 +163,7 @@ parse_refresh_link_coin (const struct TALER_EXCHANGE_RefreshLinkHandle *rlh, return GNUNET_SYSERR; } } - + /* clean up */ pub->rsa_public_key = GNUNET_CRYPTO_rsa_public_key_dup (rpub); GNUNET_JSON_parse_free (spec); @@ -204,12 +204,12 @@ parse_refresh_link_ok (struct TALER_EXCHANGE_RefreshLinkHandle *rlh, num_coins tracks the size of the 1d array we return, whilst 'i' and 'session' track the 2d array. */ - for (session=0;sessioneddsa_priv, &coin_pub.eddsa_pub); pub_str = GNUNET_STRINGS_data_to_string_alloc (&coin_pub, - sizeof (struct TALER_CoinSpendPublicKeyP)); + sizeof (struct + TALER_CoinSpendPublicKeyP)); GNUNET_asprintf (&arg_str, "/refresh/link?coin_pub=%s", pub_str); @@ -454,10 +455,10 @@ TALER_EXCHANGE_refresh_link (struct TALER_EXCHANGE_Handle *exchange, eh = TEL_curl_easy_get (rlh->url); ctx = TEAH_handle_to_context (exchange); rlh->job = GNUNET_CURL_job_add (ctx, - eh, - GNUNET_YES, - &handle_refresh_link_finished, - rlh); + eh, + GNUNET_YES, + &handle_refresh_link_finished, + rlh); return rlh; } @@ -469,7 +470,8 @@ TALER_EXCHANGE_refresh_link (struct TALER_EXCHANGE_Handle *exchange, * @param rlh the refresh link handle */ void -TALER_EXCHANGE_refresh_link_cancel (struct TALER_EXCHANGE_RefreshLinkHandle *rlh) +TALER_EXCHANGE_refresh_link_cancel (struct + TALER_EXCHANGE_RefreshLinkHandle *rlh) { if (NULL != rlh->job) { diff --git a/src/lib/exchange_api_refund.c b/src/lib/exchange_api_refund.c index 5ce0152d2..e8ae6b74a 100644 --- a/src/lib/exchange_api_refund.c +++ b/src/lib/exchange_api_refund.c @@ -96,7 +96,7 @@ verify_refund_signature_ok (const struct TALER_EXCHANGE_RefundHandle *rh, struct GNUNET_JSON_Specification spec[] = { GNUNET_JSON_spec_fixed_auto ("sig", &exchange_sig), GNUNET_JSON_spec_fixed_auto ("pub", exchange_pub), - GNUNET_JSON_spec_end() + GNUNET_JSON_spec_end () }; if (GNUNET_OK != @@ -154,7 +154,7 @@ handle_refund_finished (void *cls, case MHD_HTTP_OK: if (GNUNET_OK != verify_refund_signature_ok (rh, - j, + j, &exchange_pub)) { GNUNET_break_op (0); @@ -205,7 +205,7 @@ handle_refund_finished (void *cls, } rh->cb (rh->cb_cls, response_code, - TALER_JSON_get_error_code (j), + TALER_JSON_get_error_code (j), ep, j); TALER_EXCHANGE_refund_cancel (rh); @@ -244,20 +244,20 @@ handle_refund_finished (void *cls, */ struct TALER_EXCHANGE_RefundHandle * TALER_EXCHANGE_refund (struct TALER_EXCHANGE_Handle *exchange, - const struct TALER_Amount *amount, - const struct TALER_Amount *refund_fee, - const struct GNUNET_HashCode *h_contract_terms, - const struct TALER_CoinSpendPublicKeyP *coin_pub, - uint64_t rtransaction_id, - const struct TALER_MerchantPrivateKeyP *merchant_priv, - TALER_EXCHANGE_RefundResultCallback cb, - void *cb_cls) + const struct TALER_Amount *amount, + const struct TALER_Amount *refund_fee, + const struct GNUNET_HashCode *h_contract_terms, + const struct TALER_CoinSpendPublicKeyP *coin_pub, + uint64_t rtransaction_id, + const struct TALER_MerchantPrivateKeyP *merchant_priv, + TALER_EXCHANGE_RefundResultCallback cb, + void *cb_cls) { struct TALER_RefundRequestPS rr; struct TALER_MerchantSignatureP merchant_sig; GNUNET_assert (GNUNET_YES == - TEAH_handle_is_ready (exchange)); + TEAH_handle_is_ready (exchange)); rr.purpose.purpose = htonl (TALER_SIGNATURE_MERCHANT_REFUND); rr.purpose.size = htonl (sizeof (struct TALER_RefundRequestPS)); rr.h_contract_terms = *h_contract_terms; @@ -274,15 +274,15 @@ TALER_EXCHANGE_refund (struct TALER_EXCHANGE_Handle *exchange, &rr.purpose, &merchant_sig.eddsa_sig)); return TALER_EXCHANGE_refund2 (exchange, - amount, - refund_fee, - h_contract_terms, - coin_pub, - rtransaction_id, - &rr.merchant, - &merchant_sig, - cb, - cb_cls); + amount, + refund_fee, + h_contract_terms, + coin_pub, + rtransaction_id, + &rr.merchant, + &merchant_sig, + cb, + cb_cls); } @@ -319,33 +319,36 @@ TALER_EXCHANGE_refund (struct TALER_EXCHANGE_Handle *exchange, */ struct TALER_EXCHANGE_RefundHandle * TALER_EXCHANGE_refund2 (struct TALER_EXCHANGE_Handle *exchange, - const struct TALER_Amount *amount, - const struct TALER_Amount *refund_fee, - const struct GNUNET_HashCode *h_contract_terms, - const struct TALER_CoinSpendPublicKeyP *coin_pub, - uint64_t rtransaction_id, - const struct TALER_MerchantPublicKeyP *merchant_pub, - const struct TALER_MerchantSignatureP *merchant_sig, - TALER_EXCHANGE_RefundResultCallback cb, - void *cb_cls) + const struct TALER_Amount *amount, + const struct TALER_Amount *refund_fee, + const struct GNUNET_HashCode *h_contract_terms, + const struct TALER_CoinSpendPublicKeyP *coin_pub, + uint64_t rtransaction_id, + const struct TALER_MerchantPublicKeyP *merchant_pub, + const struct TALER_MerchantSignatureP *merchant_sig, + TALER_EXCHANGE_RefundResultCallback cb, + void *cb_cls) { struct TALER_EXCHANGE_RefundHandle *rh; struct GNUNET_CURL_Context *ctx; json_t *refund_obj; CURL *eh; -refund_obj = json_pack ("{s:o, s:o," /* amount/fee */ - " s:o, s:o," /* h_contract_terms, coin_pub */ - " s:I," /* rtransaction id */ - " s:o, s:o}", /* merchant_pub, merchant_sig */ - "refund_amount", TALER_JSON_from_amount (amount), - "refund_fee", TALER_JSON_from_amount (refund_fee), - "h_contract_terms", GNUNET_JSON_from_data_auto (h_contract_terms), - "coin_pub", GNUNET_JSON_from_data_auto (coin_pub), - "rtransaction_id", (json_int_t) rtransaction_id, - "merchant_pub", GNUNET_JSON_from_data_auto (merchant_pub), - "merchant_sig", GNUNET_JSON_from_data_auto (merchant_sig) - ); + refund_obj = json_pack ("{s:o, s:o," /* amount/fee */ + " s:o, s:o," /* h_contract_terms, coin_pub */ + " s:I," /* rtransaction id */ + " s:o, s:o}", /* merchant_pub, merchant_sig */ + "refund_amount", TALER_JSON_from_amount (amount), + "refund_fee", TALER_JSON_from_amount (refund_fee), + "h_contract_terms", GNUNET_JSON_from_data_auto ( + h_contract_terms), + "coin_pub", GNUNET_JSON_from_data_auto (coin_pub), + "rtransaction_id", (json_int_t) rtransaction_id, + "merchant_pub", GNUNET_JSON_from_data_auto ( + merchant_pub), + "merchant_sig", GNUNET_JSON_from_data_auto ( + merchant_sig) + ); if (NULL == refund_obj) { GNUNET_break (0); @@ -371,8 +374,8 @@ refund_obj = json_pack ("{s:o, s:o," /* amount/fee */ eh = TEL_curl_easy_get (rh->url); if (GNUNET_OK != TALER_curl_easy_post (&rh->ctx, - eh, - refund_obj)) + eh, + refund_obj)) { GNUNET_break (0); curl_easy_cleanup (eh); @@ -387,10 +390,10 @@ refund_obj = json_pack ("{s:o, s:o," /* amount/fee */ rh->url); ctx = TEAH_handle_to_context (exchange); rh->job = GNUNET_CURL_job_add2 (ctx, - eh, - rh->ctx.headers, - &handle_refund_finished, - rh); + eh, + rh->ctx.headers, + &handle_refund_finished, + rh); return rh; } diff --git a/src/lib/exchange_api_reserve.c b/src/lib/exchange_api_reserve.c index 3a77f606a..f90bdbb8c 100644 --- a/src/lib/exchange_api_reserve.c +++ b/src/lib/exchange_api_reserve.c @@ -111,7 +111,7 @@ parse_reserve_history (struct TALER_EXCHANGE_Handle *exchange, TALER_amount_get_zero (currency, &total_out)); uuid_off = 0; - for (off=0;offcb (rsh->cb_cls, response_code, - TALER_JSON_get_error_code (j), + TALER_JSON_get_error_code (j), j, NULL, 0, NULL); @@ -597,7 +611,8 @@ handle_reserve_status_finished (void *cls, */ struct TALER_EXCHANGE_ReserveStatusHandle * TALER_EXCHANGE_reserve_status (struct TALER_EXCHANGE_Handle *exchange, - const struct TALER_ReservePublicKeyP *reserve_pub, + const struct + TALER_ReservePublicKeyP *reserve_pub, TALER_EXCHANGE_ReserveStatusResultCallback cb, void *cb_cls) { @@ -614,7 +629,8 @@ TALER_EXCHANGE_reserve_status (struct TALER_EXCHANGE_Handle *exchange, return NULL; } pub_str = GNUNET_STRINGS_data_to_string_alloc (reserve_pub, - sizeof (struct TALER_ReservePublicKeyP)); + sizeof (struct + TALER_ReservePublicKeyP)); GNUNET_asprintf (&arg_str, "/reserve/status?reserve_pub=%s", pub_str); @@ -625,16 +641,16 @@ TALER_EXCHANGE_reserve_status (struct TALER_EXCHANGE_Handle *exchange, rsh->cb_cls = cb_cls; rsh->reserve_pub = *reserve_pub; rsh->url = TEAH_path_to_url (exchange, - arg_str); + arg_str); GNUNET_free (arg_str); eh = TEL_curl_easy_get (rsh->url); ctx = TEAH_handle_to_context (exchange); rsh->job = GNUNET_CURL_job_add (ctx, - eh, - GNUNET_NO, - &handle_reserve_status_finished, - rsh); + eh, + GNUNET_NO, + &handle_reserve_status_finished, + rsh); return rsh; } @@ -646,7 +662,8 @@ TALER_EXCHANGE_reserve_status (struct TALER_EXCHANGE_Handle *exchange, * @param rsh the reserve status request handle */ void -TALER_EXCHANGE_reserve_status_cancel (struct TALER_EXCHANGE_ReserveStatusHandle *rsh) +TALER_EXCHANGE_reserve_status_cancel (struct + TALER_EXCHANGE_ReserveStatusHandle *rsh) { if (NULL != rsh->job) { @@ -743,7 +760,7 @@ reserve_withdraw_ok (struct TALER_EXCHANGE_ReserveWithdrawHandle *wsh, struct GNUNET_JSON_Specification spec[] = { GNUNET_JSON_spec_rsa_signature ("ev_sig", &blind_sig), - GNUNET_JSON_spec_end() + GNUNET_JSON_spec_end () }; if (GNUNET_OK != @@ -793,7 +810,8 @@ reserve_withdraw_ok (struct TALER_EXCHANGE_ReserveWithdrawHandle *wsh, * @return #GNUNET_OK on success, #GNUNET_SYSERR on errors */ static int -reserve_withdraw_payment_required (struct TALER_EXCHANGE_ReserveWithdrawHandle *wsh, +reserve_withdraw_payment_required (struct + TALER_EXCHANGE_ReserveWithdrawHandle *wsh, const json_t *json) { struct TALER_Amount balance; @@ -803,7 +821,7 @@ reserve_withdraw_payment_required (struct TALER_EXCHANGE_ReserveWithdrawHandle * size_t len; struct GNUNET_JSON_Specification spec[] = { TALER_JSON_spec_amount ("balance", &balance), - GNUNET_JSON_spec_end() + GNUNET_JSON_spec_end () }; if (GNUNET_OK != @@ -832,7 +850,9 @@ reserve_withdraw_payment_required (struct TALER_EXCHANGE_ReserveWithdrawHandle * not fit on the stack. Use "GNUNET_malloc_large" as a malicious exchange may theoretically try to crash us by giving a history that does not fit into our memory. */ - rhistory = GNUNET_malloc_large (sizeof (struct TALER_EXCHANGE_ReserveHistory) * len); + rhistory = GNUNET_malloc_large (sizeof (struct + TALER_EXCHANGE_ReserveHistory) + * len); if (NULL == rhistory) { GNUNET_break (0); @@ -962,7 +982,7 @@ handle_reserve_withdraw_finished (void *cls, { wsh->cb (wsh->cb_cls, response_code, - TALER_JSON_get_error_code (j), + TALER_JSON_get_error_code (j), NULL, j); wsh->cb = NULL; @@ -1009,18 +1029,22 @@ reserve_withdraw_internal (struct TALER_EXCHANGE_Handle *exchange, wsh->cb = res_cb; wsh->cb_cls = res_cb_cls; wsh->pk = *pk; - wsh->pk.key.rsa_public_key = GNUNET_CRYPTO_rsa_public_key_dup (pk->key.rsa_public_key); + wsh->pk.key.rsa_public_key = GNUNET_CRYPTO_rsa_public_key_dup ( + pk->key.rsa_public_key); wsh->reserve_pub = *reserve_pub; wsh->c_hash = pd->c_hash; GNUNET_CRYPTO_rsa_public_key_hash (pk->key.rsa_public_key, &h_denom_pub); withdraw_obj = json_pack ("{s:o, s:o," /* denom_pub_hash and coin_ev */ " s:o, s:o}",/* reserve_pub and reserve_sig */ - "denom_pub_hash", GNUNET_JSON_from_data_auto (&h_denom_pub), + "denom_pub_hash", GNUNET_JSON_from_data_auto ( + &h_denom_pub), "coin_ev", GNUNET_JSON_from_data (pd->coin_ev, pd->coin_ev_size), - "reserve_pub", GNUNET_JSON_from_data_auto (reserve_pub), - "reserve_sig", GNUNET_JSON_from_data_auto (reserve_sig)); + "reserve_pub", GNUNET_JSON_from_data_auto ( + reserve_pub), + "reserve_sig", GNUNET_JSON_from_data_auto ( + reserve_sig)); if (NULL == withdraw_obj) { GNUNET_break (0); @@ -1034,8 +1058,8 @@ reserve_withdraw_internal (struct TALER_EXCHANGE_Handle *exchange, eh = TEL_curl_easy_get (wsh->url); if (GNUNET_OK != TALER_curl_easy_post (&wsh->ctx, - eh, - withdraw_obj)) + eh, + withdraw_obj)) { GNUNET_break (0); curl_easy_cleanup (eh); @@ -1077,9 +1101,11 @@ reserve_withdraw_internal (struct TALER_EXCHANGE_Handle *exchange, struct TALER_EXCHANGE_ReserveWithdrawHandle * TALER_EXCHANGE_reserve_withdraw (struct TALER_EXCHANGE_Handle *exchange, const struct TALER_EXCHANGE_DenomPublicKey *pk, - const struct TALER_ReservePrivateKeyP *reserve_priv, + const struct + TALER_ReservePrivateKeyP *reserve_priv, const struct TALER_PlanchetSecretsP *ps, - TALER_EXCHANGE_ReserveWithdrawResultCallback res_cb, + TALER_EXCHANGE_ReserveWithdrawResultCallback + res_cb, void *res_cb_cls) { struct TALER_Amount amount_with_fee; @@ -1158,11 +1184,15 @@ TALER_EXCHANGE_reserve_withdraw (struct TALER_EXCHANGE_Handle *exchange, */ struct TALER_EXCHANGE_ReserveWithdrawHandle * TALER_EXCHANGE_reserve_withdraw2 (struct TALER_EXCHANGE_Handle *exchange, - const struct TALER_EXCHANGE_DenomPublicKey *pk, - const struct TALER_ReserveSignatureP *reserve_sig, - const struct TALER_ReservePublicKeyP *reserve_pub, + const struct + TALER_EXCHANGE_DenomPublicKey *pk, + const struct + TALER_ReserveSignatureP *reserve_sig, + const struct + TALER_ReservePublicKeyP *reserve_pub, const struct TALER_PlanchetSecretsP *ps, - TALER_EXCHANGE_ReserveWithdrawResultCallback res_cb, + TALER_EXCHANGE_ReserveWithdrawResultCallback + res_cb, void *res_cb_cls) { struct TALER_EXCHANGE_ReserveWithdrawHandle *wsh; @@ -1196,7 +1226,9 @@ TALER_EXCHANGE_reserve_withdraw2 (struct TALER_EXCHANGE_Handle *exchange, * @param sign the withdraw sign request handle */ void -TALER_EXCHANGE_reserve_withdraw_cancel (struct TALER_EXCHANGE_ReserveWithdrawHandle *sign) +TALER_EXCHANGE_reserve_withdraw_cancel (struct + TALER_EXCHANGE_ReserveWithdrawHandle * + sign) { if (NULL != sign->job) { diff --git a/src/lib/exchange_api_track_transaction.c b/src/lib/exchange_api_track_transaction.c index 1cc99dbb8..29b85facf 100644 --- a/src/lib/exchange_api_track_transaction.c +++ b/src/lib/exchange_api_track_transaction.c @@ -88,7 +88,8 @@ struct TALER_EXCHANGE_TrackTransactionHandle * @return #GNUNET_OK if the signature is valid, #GNUNET_SYSERR if not */ static int -verify_deposit_wtid_signature_ok (const struct TALER_EXCHANGE_TrackTransactionHandle *dwh, +verify_deposit_wtid_signature_ok (const struct + TALER_EXCHANGE_TrackTransactionHandle *dwh, const json_t *json, struct TALER_ExchangePublicKeyP *exchange_pub) { @@ -97,7 +98,7 @@ verify_deposit_wtid_signature_ok (const struct TALER_EXCHANGE_TrackTransactionHa struct GNUNET_JSON_Specification spec[] = { GNUNET_JSON_spec_fixed_auto ("exchange_sig", &exchange_sig), GNUNET_JSON_spec_fixed_auto ("exchange_pub", exchange_pub), - GNUNET_JSON_spec_end() + GNUNET_JSON_spec_end () }; if (GNUNET_OK != @@ -162,7 +163,7 @@ handle_deposit_wtid_finished (void *cls, GNUNET_JSON_spec_fixed_auto ("wtid", &dwh->depconf.wtid), GNUNET_JSON_spec_absolute_time ("execution_time", &execution_time), TALER_JSON_spec_amount ("coin_contribution", &coin_contribution_s), - GNUNET_JSON_spec_end() + GNUNET_JSON_spec_end () }; if (GNUNET_OK != @@ -198,7 +199,7 @@ handle_deposit_wtid_finished (void *cls, /* Transaction known, but not executed yet */ struct GNUNET_JSON_Specification spec[] = { GNUNET_JSON_spec_absolute_time ("execution_time", &execution_time), - GNUNET_JSON_spec_end() + GNUNET_JSON_spec_end () }; if (GNUNET_OK != @@ -240,7 +241,7 @@ handle_deposit_wtid_finished (void *cls, } dwh->cb (dwh->cb_cls, response_code, - TALER_JSON_get_error_code (j), + TALER_JSON_get_error_code (j), ep, j, wtid, @@ -265,12 +266,15 @@ handle_deposit_wtid_finished (void *cls, */ struct TALER_EXCHANGE_TrackTransactionHandle * TALER_EXCHANGE_track_transaction (struct TALER_EXCHANGE_Handle *exchange, - const struct TALER_MerchantPrivateKeyP *merchant_priv, - const struct GNUNET_HashCode *h_wire, - const struct GNUNET_HashCode *h_contract_terms, - const struct TALER_CoinSpendPublicKeyP *coin_pub, - TALER_EXCHANGE_TrackTransactionCallback cb, - void *cb_cls) + const struct + TALER_MerchantPrivateKeyP *merchant_priv, + const struct GNUNET_HashCode *h_wire, + const struct + GNUNET_HashCode *h_contract_terms, + const struct + TALER_CoinSpendPublicKeyP *coin_pub, + TALER_EXCHANGE_TrackTransactionCallback cb, + void *cb_cls) { struct TALER_DepositTrackPS dtp; struct TALER_MerchantSignatureP merchant_sig; @@ -301,10 +305,14 @@ TALER_EXCHANGE_track_transaction (struct TALER_EXCHANGE_Handle *exchange, " s:o," /* coin_pub */ " s:o, s:o}", /* merchant_pub, merchant_sig */ "H_wire", GNUNET_JSON_from_data_auto (h_wire), - "h_contract_terms", GNUNET_JSON_from_data_auto (h_contract_terms), - "coin_pub", GNUNET_JSON_from_data_auto (coin_pub), - "merchant_pub", GNUNET_JSON_from_data_auto (&dtp.merchant), - "merchant_sig", GNUNET_JSON_from_data_auto (&merchant_sig)); + "h_contract_terms", GNUNET_JSON_from_data_auto ( + h_contract_terms), + "coin_pub", GNUNET_JSON_from_data_auto ( + coin_pub), + "merchant_pub", GNUNET_JSON_from_data_auto ( + &dtp.merchant), + "merchant_sig", GNUNET_JSON_from_data_auto ( + &merchant_sig)); if (NULL == deposit_wtid_obj) { GNUNET_break (0); @@ -325,8 +333,8 @@ TALER_EXCHANGE_track_transaction (struct TALER_EXCHANGE_Handle *exchange, eh = TEL_curl_easy_get (dwh->url); if (GNUNET_OK != TALER_curl_easy_post (&dwh->ctx, - eh, - deposit_wtid_obj)) + eh, + deposit_wtid_obj)) { GNUNET_break (0); curl_easy_cleanup (eh); @@ -353,7 +361,9 @@ TALER_EXCHANGE_track_transaction (struct TALER_EXCHANGE_Handle *exchange, * @param dwh the wire deposits request handle */ void -TALER_EXCHANGE_track_transaction_cancel (struct TALER_EXCHANGE_TrackTransactionHandle *dwh) +TALER_EXCHANGE_track_transaction_cancel (struct + TALER_EXCHANGE_TrackTransactionHandle * + dwh) { if (NULL != dwh->job) { diff --git a/src/lib/exchange_api_track_transfer.c b/src/lib/exchange_api_track_transfer.c index 88043b7ba..419998a2c 100644 --- a/src/lib/exchange_api_track_transfer.c +++ b/src/lib/exchange_api_track_transfer.c @@ -80,7 +80,8 @@ struct TALER_EXCHANGE_TrackTransferHandle * #GNUNET_SYSERR if the response was bogus */ static int -check_track_transfer_response_ok (struct TALER_EXCHANGE_TrackTransferHandle *wdh, +check_track_transfer_response_ok (struct + TALER_EXCHANGE_TrackTransferHandle *wdh, const json_t *json) { json_t *details_j; @@ -102,7 +103,7 @@ check_track_transfer_response_ok (struct TALER_EXCHANGE_TrackTransferHandle *wdh GNUNET_JSON_spec_json ("deposits", &details_j), GNUNET_JSON_spec_fixed_auto ("exchange_sig", &exchange_sig), GNUNET_JSON_spec_fixed_auto ("exchange_pub", &exchange_pub), - GNUNET_JSON_spec_end() + GNUNET_JSON_spec_end () }; if (GNUNET_OK != @@ -129,16 +130,17 @@ check_track_transfer_response_ok (struct TALER_EXCHANGE_TrackTransferHandle *wdh struct TALER_WireDepositDataPS wdp; hash_context = GNUNET_CRYPTO_hash_context_start (); - for (i=0;ih_contract_terms), + GNUNET_JSON_spec_fixed_auto ("h_contract_terms", + &detail->h_contract_terms), GNUNET_JSON_spec_fixed_auto ("coin_pub", &detail->coin_pub), TALER_JSON_spec_amount ("deposit_value", &detail->coin_value), TALER_JSON_spec_amount ("deposit_fee", &detail->coin_fee), - GNUNET_JSON_spec_end() + GNUNET_JSON_spec_end () }; if (GNUNET_OK != @@ -175,7 +177,8 @@ check_track_transfer_response_ok (struct TALER_EXCHANGE_TrackTransferHandle *wdh } GNUNET_CRYPTO_hash_context_read (hash_context, &dd, - sizeof (struct TALER_WireDepositDetailP)); + sizeof (struct + TALER_WireDepositDetailP)); } /* Check signature */ wdp.purpose.purpose = htonl (TALER_SIGNATURE_EXCHANGE_CONFIRM_WIRE_DEPOSIT); @@ -189,7 +192,8 @@ check_track_transfer_response_ok (struct TALER_EXCHANGE_TrackTransferHandle *wdh GNUNET_CRYPTO_hash_context_finish (hash_context, &wdp.h_details); if (GNUNET_OK != - TALER_EXCHANGE_test_signing_key (TALER_EXCHANGE_get_keys (wdh->exchange), + TALER_EXCHANGE_test_signing_key (TALER_EXCHANGE_get_keys ( + wdh->exchange), &exchange_pub)) { GNUNET_break_op (0); @@ -197,10 +201,10 @@ check_track_transfer_response_ok (struct TALER_EXCHANGE_TrackTransferHandle *wdh return GNUNET_SYSERR; } if (GNUNET_OK != GNUNET_CRYPTO_eddsa_verify - (TALER_SIGNATURE_EXCHANGE_CONFIRM_WIRE_DEPOSIT, - &wdp.purpose, - &exchange_sig.eddsa_signature, - &exchange_pub.eddsa_pub)) + (TALER_SIGNATURE_EXCHANGE_CONFIRM_WIRE_DEPOSIT, + &wdp.purpose, + &exchange_sig.eddsa_signature, + &exchange_pub.eddsa_pub)) { GNUNET_break_op (0); GNUNET_JSON_parse_free (spec); @@ -226,7 +230,7 @@ check_track_transfer_response_ok (struct TALER_EXCHANGE_TrackTransferHandle *wdh } wdh->cb (wdh->cb_cls, MHD_HTTP_OK, - TALER_EC_NONE, + TALER_EC_NONE, &exchange_pub, json, &h_wire, @@ -299,7 +303,7 @@ handle_track_transfer_finished (void *cls, } wdh->cb (wdh->cb_cls, response_code, - TALER_JSON_get_error_code (j), + TALER_JSON_get_error_code (j), NULL, j, NULL, @@ -323,7 +327,8 @@ handle_track_transfer_finished (void *cls, */ struct TALER_EXCHANGE_TrackTransferHandle * TALER_EXCHANGE_track_transfer (struct TALER_EXCHANGE_Handle *exchange, - const struct TALER_WireTransferIdentifierRawP *wtid, + const struct + TALER_WireTransferIdentifierRawP *wtid, TALER_EXCHANGE_TrackTransferCallback cb, void *cb_cls) { @@ -346,22 +351,23 @@ TALER_EXCHANGE_track_transfer (struct TALER_EXCHANGE_Handle *exchange, wdh->cb_cls = cb_cls; buf = GNUNET_STRINGS_data_to_string_alloc (wtid, - sizeof (struct TALER_WireTransferIdentifierRawP)); + sizeof (struct + TALER_WireTransferIdentifierRawP)); GNUNET_asprintf (&path, "/track/transfer?wtid=%s", buf); wdh->url = TEAH_path_to_url (wdh->exchange, - path); + path); GNUNET_free (buf); GNUNET_free (path); eh = TEL_curl_easy_get (wdh->url); ctx = TEAH_handle_to_context (exchange); wdh->job = GNUNET_CURL_job_add (ctx, - eh, - GNUNET_YES, - &handle_track_transfer_finished, - wdh); + eh, + GNUNET_YES, + &handle_track_transfer_finished, + wdh); return wdh; } @@ -373,7 +379,8 @@ TALER_EXCHANGE_track_transfer (struct TALER_EXCHANGE_Handle *exchange, * @param wdh the wire deposits request handle */ void -TALER_EXCHANGE_track_transfer_cancel (struct TALER_EXCHANGE_TrackTransferHandle *wdh) +TALER_EXCHANGE_track_transfer_cancel (struct + TALER_EXCHANGE_TrackTransferHandle *wdh) { if (NULL != wdh->job) { diff --git a/src/lib/exchange_api_wire.c b/src/lib/exchange_api_wire.c index 85d1835cf..8bfa4ed12 100644 --- a/src/lib/exchange_api_wire.c +++ b/src/lib/exchange_api_wire.c @@ -149,12 +149,12 @@ parse_fees (json_t *fees) TALER_JSON_spec_amount ("wire_fee", &wa->wire_fee), TALER_JSON_spec_amount ("closing_fee", - &wa->closing_fee), + &wa->closing_fee), GNUNET_JSON_spec_absolute_time ("start_date", &wa->start_date), GNUNET_JSON_spec_absolute_time ("end_date", &wa->end_date), - GNUNET_JSON_spec_end() + GNUNET_JSON_spec_end () }; if (GNUNET_OK != @@ -188,7 +188,7 @@ static const struct TALER_EXCHANGE_WireAggregateFees * lookup_fee (const struct FeeMap *fm, const char *method) { - for (;NULL != fm; fm = fm->next) + for (; NULL != fm; fm = fm->next) if (0 == strcasecmp (fm->method, method)) return fm->fee_list; @@ -230,7 +230,7 @@ handle_wire_finished (void *cls, struct GNUNET_JSON_Specification spec[] = { GNUNET_JSON_spec_json ("accounts", &accounts), GNUNET_JSON_spec_json ("fees", &fees), - GNUNET_JSON_spec_end() + GNUNET_JSON_spec_end () }; if (GNUNET_OK != @@ -268,14 +268,14 @@ handle_wire_finished (void *cls, { struct TALER_EXCHANGE_WireAccount was[num_accounts]; - for (unsigned int i=0;iurl), GNUNET_JSON_spec_fixed_auto ("master_sig", &wa->master_sig), - GNUNET_JSON_spec_end() + GNUNET_JSON_spec_end () }; char *method; diff --git a/src/lib/teah_common.c b/src/lib/teah_common.c index cc8a23754..3e56c7536 100644 --- a/src/lib/teah_common.c +++ b/src/lib/teah_common.c @@ -78,17 +78,17 @@ TALER_curl_easy_post (struct TEAH_PostContext *ctx, ctx->json_enc = (char *) cbuf; } GNUNET_assert - (NULL != (ctx->headers = curl_slist_append - (ctx->headers, - "Content-Encoding: deflate"))); + (NULL != (ctx->headers = curl_slist_append + (ctx->headers, + "Content-Encoding: deflate"))); #else ctx->json_enc = str; #endif GNUNET_assert - (NULL != (ctx->headers = curl_slist_append - (ctx->headers, - "Content-Type: application/json"))); + (NULL != (ctx->headers = curl_slist_append + (ctx->headers, + "Content-Type: application/json"))); GNUNET_assert (CURLE_OK == curl_easy_setopt (eh, diff --git a/src/lib/test_auditor_api.c b/src/lib/test_auditor_api.c index f8861bc43..656819aa3 100644 --- a/src/lib/test_auditor_api.c +++ b/src/lib/test_auditor_api.c @@ -42,7 +42,8 @@ */ #define CONFIG_FILE "test_auditor_api.conf" -#define CONFIG_FILE_EXPIRE_RESERVE_NOW "test_auditor_api_expire_reserve_now.conf" +#define CONFIG_FILE_EXPIRE_RESERVE_NOW \ + "test_auditor_api_expire_reserve_now.conf" /** * URL of the fakebank. Obtained from CONFIG_FILE's @@ -91,7 +92,7 @@ static char *exchange_url; * @param label label to use for the command. */ #define CMD_EXEC_WIREWATCH(label) \ - TALER_TESTING_cmd_exec_wirewatch (label, CONFIG_FILE) + TALER_TESTING_cmd_exec_wirewatch (label, CONFIG_FILE) /** * Execute the taler-exchange-aggregator command with @@ -100,7 +101,7 @@ static char *exchange_url; * @param label label to use for the command. */ #define CMD_EXEC_AGGREGATOR(label) \ - TALER_TESTING_cmd_exec_aggregator (label, CONFIG_FILE) + TALER_TESTING_cmd_exec_aggregator (label, CONFIG_FILE) /** * Run wire transfer of funds from some user's account to the @@ -110,9 +111,11 @@ static char *exchange_url; * @param amount amount to transfer, i.e. "EUR:1" */ #define CMD_TRANSFER_TO_EXCHANGE(label,amount) \ - TALER_TESTING_cmd_fakebank_transfer (label, amount, \ - fakebank_url, USER_ACCOUNT_NO, EXCHANGE_ACCOUNT_NO, \ - USER_LOGIN_NAME, USER_LOGIN_PASS, exchange_url) + TALER_TESTING_cmd_fakebank_transfer (label, amount, \ + fakebank_url, USER_ACCOUNT_NO, \ + EXCHANGE_ACCOUNT_NO, \ + USER_LOGIN_NAME, USER_LOGIN_PASS, \ + exchange_url) /** * Run wire transfer of funds from some user's account to the @@ -122,10 +125,10 @@ static char *exchange_url; * @param amount amount to transfer, i.e. "EUR:1" */ #define CMD_TRANSFER_TO_EXCHANGE_SUBJECT(label,amount,subject) \ - TALER_TESTING_cmd_fakebank_transfer_with_subject \ - (label, amount, fakebank_url, USER_ACCOUNT_NO, \ - EXCHANGE_ACCOUNT_NO, USER_LOGIN_NAME, USER_LOGIN_PASS, \ - subject, exchange_url) + TALER_TESTING_cmd_fakebank_transfer_with_subject \ + (label, amount, fakebank_url, USER_ACCOUNT_NO, \ + EXCHANGE_ACCOUNT_NO, USER_LOGIN_NAME, USER_LOGIN_PASS, \ + subject, exchange_url) /** * Run the taler-auditor. @@ -270,88 +273,88 @@ run (void *cls, */ TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-499c", exchange_url, - "EUR:4.98", 2, 42), + "EUR:4.98", 2, 42), TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-99c1", exchange_url, - "EUR:0.98", 2, 42), + "EUR:0.98", 2, 42), TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-99c", exchange_url, - "EUR:0.08", 2, 43), + "EUR:0.08", 2, 43), TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-aai-1", exchange_url, - "EUR:5.01", 42, 2), + "EUR:5.01", 42, 2), TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-aai-2", exchange_url, - "EUR:5.01", 42, 2), + "EUR:5.01", 42, 2), /* The following transactions got originated within * the "massive deposit confirms" batch. */ TALER_TESTING_cmd_check_bank_transfer ("check-massive-transfer", - exchange_url, - "EUR:10.10", - 42, - 2), + exchange_url, + "EUR:10.10", + 42, + 2), TALER_TESTING_cmd_check_bank_transfer ("check-massive-transfer-1", - exchange_url, - "EUR:0.98", - 2, - 43), + exchange_url, + "EUR:0.98", + 2, + 43), TALER_TESTING_cmd_check_bank_transfer ("check-massive-transfer-2", - exchange_url, - "EUR:0.98", - 2, - 43), + exchange_url, + "EUR:0.98", + 2, + 43), TALER_TESTING_cmd_check_bank_transfer ("check-massive-transfer-3", - exchange_url, - "EUR:0.98", - 2, - 43), + exchange_url, + "EUR:0.98", + 2, + 43), TALER_TESTING_cmd_check_bank_transfer ("check-massive-transfer-4", - exchange_url, - "EUR:0.98", - 2, - 43), + exchange_url, + "EUR:0.98", + 2, + 43), TALER_TESTING_cmd_check_bank_transfer ("check-massive-transfer-5", - exchange_url, - "EUR:0.98", - 2, - 43), + exchange_url, + "EUR:0.98", + 2, + 43), TALER_TESTING_cmd_check_bank_transfer ("check-massive-transfer-6", - exchange_url, - "EUR:0.98", - 2, - 43), + exchange_url, + "EUR:0.98", + 2, + 43), TALER_TESTING_cmd_check_bank_transfer ("check-massive-transfer-7", - exchange_url, - "EUR:0.98", - 2, - 43), + exchange_url, + "EUR:0.98", + 2, + 43), TALER_TESTING_cmd_check_bank_transfer ("check-massive-transfer-8", - exchange_url, - "EUR:0.98", - 2, - 43), + exchange_url, + "EUR:0.98", + 2, + 43), TALER_TESTING_cmd_check_bank_transfer ("check-massive-transfer-9", - exchange_url, - "EUR:0.98", - 2, - 43), + exchange_url, + "EUR:0.98", + 2, + 43), TALER_TESTING_cmd_check_bank_transfer ("check-massive-transfer-10", - exchange_url, - "EUR:0.98", - 2, - 43), + exchange_url, + "EUR:0.98", + 2, + 43), TALER_TESTING_cmd_check_bank_empty ("check_bank_empty"), TALER_TESTING_cmd_end () }; @@ -379,12 +382,12 @@ run (void *cls, "withdraw-coin-unaggregated", 0, TALER_TESTING_make_wire_details - (43, - fakebank_url), + (43, + fakebank_url), "{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}", GNUNET_TIME_relative_multiply - (GNUNET_TIME_UNIT_YEARS, - 3000), + (GNUNET_TIME_UNIT_YEARS, + 3000), "EUR:5", MHD_HTTP_OK), CMD_EXEC_AGGREGATOR ("aggregation-attempt"), @@ -593,121 +596,121 @@ run (void *cls, MHD_HTTP_OK), TALER_TESTING_cmd_deposit ("massive-deposit-1", - "massive-withdraw-1", - 0, - TALER_TESTING_make_wire_details - (43, - fakebank_url), - "{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}", - GNUNET_TIME_UNIT_ZERO, - "EUR:1", - MHD_HTTP_OK), + "massive-withdraw-1", + 0, + TALER_TESTING_make_wire_details + (43, + fakebank_url), + "{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}", + GNUNET_TIME_UNIT_ZERO, + "EUR:1", + MHD_HTTP_OK), TALER_TESTING_cmd_deposit ("massive-deposit-2", - "massive-withdraw-2", - 0, - TALER_TESTING_make_wire_details - (43, - fakebank_url), - "{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}", - GNUNET_TIME_UNIT_ZERO, - "EUR:1", - MHD_HTTP_OK), + "massive-withdraw-2", + 0, + TALER_TESTING_make_wire_details + (43, + fakebank_url), + "{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}", + GNUNET_TIME_UNIT_ZERO, + "EUR:1", + MHD_HTTP_OK), TALER_TESTING_cmd_deposit ("massive-deposit-3", - "massive-withdraw-3", - 0, - TALER_TESTING_make_wire_details - (43, - fakebank_url), - "{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}", - GNUNET_TIME_UNIT_ZERO, - "EUR:1", - MHD_HTTP_OK), + "massive-withdraw-3", + 0, + TALER_TESTING_make_wire_details + (43, + fakebank_url), + "{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}", + GNUNET_TIME_UNIT_ZERO, + "EUR:1", + MHD_HTTP_OK), TALER_TESTING_cmd_deposit ("massive-deposit-4", - "massive-withdraw-4", - 0, - TALER_TESTING_make_wire_details - (43, - fakebank_url), - "{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}", - GNUNET_TIME_UNIT_ZERO, - "EUR:1", - MHD_HTTP_OK), + "massive-withdraw-4", + 0, + TALER_TESTING_make_wire_details + (43, + fakebank_url), + "{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}", + GNUNET_TIME_UNIT_ZERO, + "EUR:1", + MHD_HTTP_OK), TALER_TESTING_cmd_deposit ("massive-deposit-5", - "massive-withdraw-5", - 0, - TALER_TESTING_make_wire_details - (43, - fakebank_url), - "{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}", - GNUNET_TIME_UNIT_ZERO, - "EUR:1", - MHD_HTTP_OK), + "massive-withdraw-5", + 0, + TALER_TESTING_make_wire_details + (43, + fakebank_url), + "{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}", + GNUNET_TIME_UNIT_ZERO, + "EUR:1", + MHD_HTTP_OK), TALER_TESTING_cmd_deposit ("massive-deposit-6", - "massive-withdraw-6", - 0, - TALER_TESTING_make_wire_details - (43, - fakebank_url), - "{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}", - GNUNET_TIME_UNIT_ZERO, - "EUR:1", - MHD_HTTP_OK), + "massive-withdraw-6", + 0, + TALER_TESTING_make_wire_details + (43, + fakebank_url), + "{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}", + GNUNET_TIME_UNIT_ZERO, + "EUR:1", + MHD_HTTP_OK), TALER_TESTING_cmd_deposit ("massive-deposit-7", - "massive-withdraw-7", - 0, - TALER_TESTING_make_wire_details - (43, - fakebank_url), - "{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}", - GNUNET_TIME_UNIT_ZERO, - "EUR:1", - MHD_HTTP_OK), + "massive-withdraw-7", + 0, + TALER_TESTING_make_wire_details + (43, + fakebank_url), + "{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}", + GNUNET_TIME_UNIT_ZERO, + "EUR:1", + MHD_HTTP_OK), TALER_TESTING_cmd_deposit ("massive-deposit-8", - "massive-withdraw-8", - 0, - TALER_TESTING_make_wire_details - (43, - fakebank_url), - "{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}", - GNUNET_TIME_UNIT_ZERO, - "EUR:1", - MHD_HTTP_OK), + "massive-withdraw-8", + 0, + TALER_TESTING_make_wire_details + (43, + fakebank_url), + "{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}", + GNUNET_TIME_UNIT_ZERO, + "EUR:1", + MHD_HTTP_OK), TALER_TESTING_cmd_deposit ("massive-deposit-9", - "massive-withdraw-9", - 0, - TALER_TESTING_make_wire_details - (43, - fakebank_url), - "{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}", - GNUNET_TIME_UNIT_ZERO, - "EUR:1", - MHD_HTTP_OK), + "massive-withdraw-9", + 0, + TALER_TESTING_make_wire_details + (43, + fakebank_url), + "{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}", + GNUNET_TIME_UNIT_ZERO, + "EUR:1", + MHD_HTTP_OK), TALER_TESTING_cmd_deposit ("massive-deposit-10", - "massive-withdraw-10", - 0, - TALER_TESTING_make_wire_details - (43, - fakebank_url), - "{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}", - GNUNET_TIME_UNIT_ZERO, - "EUR:1", - MHD_HTTP_OK), + "massive-withdraw-10", + 0, + TALER_TESTING_make_wire_details + (43, + fakebank_url), + "{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}", + GNUNET_TIME_UNIT_ZERO, + "EUR:1", + MHD_HTTP_OK), TALER_TESTING_cmd_deposit_confirmation ("deposit-confirmation", is->auditor, "massive-deposit-10", 0, "EUR:0.99", MHD_HTTP_OK), - CMD_RUN_AUDITOR("massive-auditor"), + CMD_RUN_AUDITOR ("massive-auditor"), TALER_TESTING_cmd_end () }; @@ -734,8 +737,8 @@ run (void *cls, refund), TALER_TESTING_cmd_batch ("payback", payback), - CMD_RUN_AUDITOR("normal-auditor"), - CMD_RUN_WIRE_AUDITOR("normal-wire-auditor"), + CMD_RUN_AUDITOR ("normal-auditor"), + CMD_RUN_WIRE_AUDITOR ("normal-wire-auditor"), TALER_TESTING_cmd_end () }; @@ -747,7 +750,7 @@ run (void *cls, int main (int argc, - char * const *argv) + char *const *argv) { /* These environment variables get in the way... */ unsetenv ("XDG_DATA_HOME"); @@ -756,10 +759,10 @@ main (int argc, "INFO", NULL); if (NULL == (fakebank_url - /* Check fakebank port is available and config cares - * about bank url. */ - = TALER_TESTING_prepare_fakebank (CONFIG_FILE, - "account-2"))) + /* Check fakebank port is available and config cares + * about bank url. */ + = TALER_TESTING_prepare_fakebank (CONFIG_FILE, + "account-2"))) return 77; TALER_TESTING_cleanup_files (CONFIG_FILE); /* @helpers. Run keyup, create tables, ... Note: it diff --git a/src/lib/test_auditor_api_version.c b/src/lib/test_auditor_api_version.c index 7a21430da..696e3db27 100644 --- a/src/lib/test_auditor_api_version.c +++ b/src/lib/test_auditor_api_version.c @@ -87,8 +87,8 @@ do_timeout (void *cls) */ static void version_cb (void *cls, - const struct TALER_AUDITOR_VersionInformation *vi, - enum TALER_AUDITOR_VersionCompatibility compat) + const struct TALER_AUDITOR_VersionInformation *vi, + enum TALER_AUDITOR_VersionCompatibility compat) { if ( (NULL != vi) && (TALER_AUDITOR_VC_MATCH == compat) ) @@ -109,29 +109,29 @@ static void run (void *cls) { const char *auditor_url = "http://localhost:8083/"; - + (void) cls; ctx = GNUNET_CURL_init (&GNUNET_CURL_gnunet_scheduler_reschedule, - &rc); + &rc); rc = GNUNET_CURL_gnunet_rc_create (ctx); ah = TALER_AUDITOR_connect (ctx, - auditor_url, - &version_cb, - NULL); + auditor_url, + &version_cb, + NULL); GNUNET_SCHEDULER_add_shutdown (&do_shutdown, - NULL); + NULL); tt = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, - &do_timeout, - NULL); + &do_timeout, + NULL); } int main (int argc, - char * const *argv) + char *const *argv) { struct GNUNET_OS_Process *proc; - + /* These environment variables get in the way... */ unsetenv ("XDG_DATA_HOME"); unsetenv ("XDG_CONFIG_HOME"); @@ -148,12 +148,12 @@ main (int argc, if (NULL == proc) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Failed to run `taler-auditor-httpd`," + "Failed to run `taler-auditor-httpd`," " is your PATH correct?\n"); return 77; } GNUNET_SCHEDULER_run (&run, - NULL); + NULL); GNUNET_OS_process_kill (proc, SIGTERM); GNUNET_OS_process_wait (proc); GNUNET_OS_process_destroy (proc); diff --git a/src/lib/test_exchange_api.c b/src/lib/test_exchange_api.c index 33a2df9dd..eeccd3bc2 100644 --- a/src/lib/test_exchange_api.c +++ b/src/lib/test_exchange_api.c @@ -42,7 +42,8 @@ */ #define CONFIG_FILE "test_exchange_api.conf" -#define CONFIG_FILE_EXPIRE_RESERVE_NOW "test_exchange_api_expire_reserve_now.conf" +#define CONFIG_FILE_EXPIRE_RESERVE_NOW \ + "test_exchange_api_expire_reserve_now.conf" /** * Is the configuration file is set to include wire format 'ebics'? @@ -99,7 +100,7 @@ static char *auditor_url; * @param label label to use for the command. */ #define CMD_EXEC_WIREWATCH(label) \ - TALER_TESTING_cmd_exec_wirewatch (label, CONFIG_FILE) + TALER_TESTING_cmd_exec_wirewatch (label, CONFIG_FILE) /** * Execute the taler-exchange-aggregator command with @@ -108,7 +109,7 @@ static char *auditor_url; * @param label label to use for the command. */ #define CMD_EXEC_AGGREGATOR(label) \ - TALER_TESTING_cmd_exec_aggregator (label, CONFIG_FILE) + TALER_TESTING_cmd_exec_aggregator (label, CONFIG_FILE) /** * Run wire transfer of funds from some user's account to the @@ -118,9 +119,11 @@ static char *auditor_url; * @param amount amount to transfer, i.e. "EUR:1" */ #define CMD_TRANSFER_TO_EXCHANGE(label,amount) \ - TALER_TESTING_cmd_fakebank_transfer (label, amount, \ - fakebank_url, USER_ACCOUNT_NO, EXCHANGE_ACCOUNT_NO, \ - USER_LOGIN_NAME, USER_LOGIN_PASS, exchange_url) + TALER_TESTING_cmd_fakebank_transfer (label, amount, \ + fakebank_url, USER_ACCOUNT_NO, \ + EXCHANGE_ACCOUNT_NO, \ + USER_LOGIN_NAME, USER_LOGIN_PASS, \ + exchange_url) /** * Run wire transfer of funds from some user's account to the @@ -130,10 +133,10 @@ static char *auditor_url; * @param amount amount to transfer, i.e. "EUR:1" */ #define CMD_TRANSFER_TO_EXCHANGE_SUBJECT(label,amount,subject) \ - TALER_TESTING_cmd_fakebank_transfer_with_subject \ - (label, amount, fakebank_url, USER_ACCOUNT_NO, \ - EXCHANGE_ACCOUNT_NO, USER_LOGIN_NAME, USER_LOGIN_PASS, \ - subject, exchange_url) + TALER_TESTING_cmd_fakebank_transfer_with_subject \ + (label, amount, fakebank_url, USER_ACCOUNT_NO, \ + EXCHANGE_ACCOUNT_NO, USER_LOGIN_NAME, USER_LOGIN_PASS, \ + subject, exchange_url) /** * Main function that will tell the interpreter what commands to @@ -214,10 +217,10 @@ run (void *cls, */ TALER_TESTING_cmd_deposit ("deposit-simple", "withdraw-coin-1", 0, - TALER_TESTING_make_wire_details (42, - fakebank_url), - "{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}", - GNUNET_TIME_UNIT_ZERO, "EUR:5", MHD_HTTP_OK), + TALER_TESTING_make_wire_details (42, + fakebank_url), + "{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}", + GNUNET_TIME_UNIT_ZERO, "EUR:5", MHD_HTTP_OK), /** * Try to overdraw. @@ -232,10 +235,10 @@ run (void *cls, */ TALER_TESTING_cmd_deposit ("deposit-double-1", "withdraw-coin-1", 0, - TALER_TESTING_make_wire_details (43, - fakebank_url), - "{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}", - GNUNET_TIME_UNIT_ZERO, "EUR:5", MHD_HTTP_FORBIDDEN), + TALER_TESTING_make_wire_details (43, + fakebank_url), + "{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}", + GNUNET_TIME_UNIT_ZERO, "EUR:5", MHD_HTTP_FORBIDDEN), /** * Try to double spend using a different transaction id. @@ -248,20 +251,20 @@ run (void *cls, */ TALER_TESTING_cmd_deposit ("deposit-double-1", "withdraw-coin-1", 0, - TALER_TESTING_make_wire_details (43, - fakebank_url), - "{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}", - GNUNET_TIME_UNIT_ZERO, "EUR:5", MHD_HTTP_FORBIDDEN), + TALER_TESTING_make_wire_details (43, + fakebank_url), + "{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}", + GNUNET_TIME_UNIT_ZERO, "EUR:5", MHD_HTTP_FORBIDDEN), /** * Try to double spend with different proposal. */ TALER_TESTING_cmd_deposit ("deposit-double-2", "withdraw-coin-1", 0, - TALER_TESTING_make_wire_details (43, - fakebank_url), - "{\"items\":[{\"name\":\"ice cream\",\"value\":2}]}", - GNUNET_TIME_UNIT_ZERO, "EUR:5", MHD_HTTP_FORBIDDEN), + TALER_TESTING_make_wire_details (43, + fakebank_url), + "{\"items\":[{\"name\":\"ice cream\",\"value\":2}]}", + GNUNET_TIME_UNIT_ZERO, "EUR:5", MHD_HTTP_FORBIDDEN), TALER_TESTING_cmd_end () }; @@ -288,9 +291,9 @@ run (void *cls, */ TALER_TESTING_cmd_withdraw_amount ("refresh-withdraw-coin-1", - "refresh-create-reserve-1", - "EUR:5", - MHD_HTTP_OK), + "refresh-create-reserve-1", + "EUR:5", + MHD_HTTP_OK), /** * Try to partially spend (deposit) 1 EUR of the 5 EUR coin * (in full) (merchant would receive EUR:0.99 due to 1 ct @@ -298,74 +301,74 @@ run (void *cls, */ TALER_TESTING_cmd_deposit ("refresh-deposit-partial", - "refresh-withdraw-coin-1", 0, - TALER_TESTING_make_wire_details (42, - fakebank_url), - "{\"items\":[{\"name\":\"ice cream\",\ + "refresh-withdraw-coin-1", 0, + TALER_TESTING_make_wire_details (42, + fakebank_url), + "{\"items\":[{\"name\":\"ice cream\",\ \"value\":\"EUR:1\"}]}", - GNUNET_TIME_UNIT_ZERO, "EUR:1", MHD_HTTP_OK), + GNUNET_TIME_UNIT_ZERO, "EUR:1", MHD_HTTP_OK), /** * Melt the rest of the coin's value * (EUR:4.00 = 3x EUR:1.03 + 7x EUR:0.13) */ TALER_TESTING_cmd_refresh_melt_double ("refresh-melt-1", - "refresh-withdraw-coin-1", - MHD_HTTP_OK, - NULL), + "refresh-withdraw-coin-1", + MHD_HTTP_OK, + NULL), /** * Complete (successful) melt operation, and * withdraw the coins */ TALER_TESTING_cmd_refresh_reveal ("refresh-reveal-1", - "refresh-melt-1", MHD_HTTP_OK), + "refresh-melt-1", MHD_HTTP_OK), /** * Do it again to check idempotency */ TALER_TESTING_cmd_refresh_reveal ("refresh-reveal-1-idempotency", - "refresh-melt-1", MHD_HTTP_OK), + "refresh-melt-1", MHD_HTTP_OK), /** * Test that /refresh/link works */ TALER_TESTING_cmd_refresh_link ("refresh-link-1", - "refresh-reveal-1", MHD_HTTP_OK), + "refresh-reveal-1", MHD_HTTP_OK), /** * Try to spend a refreshed EUR:1 coin */ TALER_TESTING_cmd_deposit ("refresh-deposit-refreshed-1a", - "refresh-reveal-1-idempotency", 0, - TALER_TESTING_make_wire_details (42, - fakebank_url), - "{\"items\":[{\"name\":\"ice cream\",\ + "refresh-reveal-1-idempotency", 0, + TALER_TESTING_make_wire_details (42, + fakebank_url), + "{\"items\":[{\"name\":\"ice cream\",\ \"value\":3}]}", - GNUNET_TIME_UNIT_ZERO, "EUR:1", MHD_HTTP_OK), + GNUNET_TIME_UNIT_ZERO, "EUR:1", MHD_HTTP_OK), /** * Try to spend a refreshed EUR:0.1 coin */ TALER_TESTING_cmd_deposit ("refresh-deposit-refreshed-1b", - "refresh-reveal-1", 3, - TALER_TESTING_make_wire_details (43, - fakebank_url), - "{\"items\":[{\"name\":\"ice cream\",\ + "refresh-reveal-1", 3, + TALER_TESTING_make_wire_details (43, + fakebank_url), + "{\"items\":[{\"name\":\"ice cream\",\ \"value\":3}]}", - GNUNET_TIME_UNIT_ZERO, "EUR:0.1", MHD_HTTP_OK), + GNUNET_TIME_UNIT_ZERO, "EUR:0.1", MHD_HTTP_OK), /* Test running a failing melt operation (same operation * again must fail) */ TALER_TESTING_cmd_refresh_melt ("refresh-melt-failing", - "refresh-withdraw-coin-1", - MHD_HTTP_FORBIDDEN, - NULL), + "refresh-withdraw-coin-1", + MHD_HTTP_FORBIDDEN, + NULL), /* FIXME: also test with coin that was already melted * (signature differs from coin that was deposited...) */ @@ -380,8 +383,8 @@ run (void *cls, * the exchange knows about the deposit, but has no WTID yet. */ TALER_TESTING_cmd_track_transaction - ("deposit-wtid-found", - "deposit-simple", 0, MHD_HTTP_ACCEPTED, NULL), + ("deposit-wtid-found", + "deposit-simple", 0, MHD_HTTP_ACCEPTED, NULL), /** * Try resolving a deposit's WTID for a failed deposit. @@ -389,8 +392,8 @@ run (void *cls, * exchange does NOT know about the deposit. */ TALER_TESTING_cmd_track_transaction - ("deposit-wtid-failing", - "deposit-double-2", 0, MHD_HTTP_NOT_FOUND, NULL), + ("deposit-wtid-failing", + "deposit-double-2", 0, MHD_HTTP_NOT_FOUND, NULL), /** * Try resolving an undefined (all zeros) WTID; this @@ -399,7 +402,7 @@ run (void *cls, */ TALER_TESTING_cmd_track_transfer_empty ("wire-deposit-failing", - NULL, 0, MHD_HTTP_NOT_FOUND), + NULL, 0, MHD_HTTP_NOT_FOUND), /** * Run transfers. Note that _actual_ aggregation will NOT @@ -415,23 +418,23 @@ run (void *cls, */ TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-499c", exchange_url, - "EUR:4.98", 2, 42), + "EUR:4.98", 2, 42), TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-99c1", exchange_url, - "EUR:0.98", 2, 42), + "EUR:0.98", 2, 42), TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-99c2", exchange_url, - "EUR:0.98", 2, 42), + "EUR:0.98", 2, 42), TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-99c", exchange_url, - "EUR:0.08", 2, 43), + "EUR:0.08", 2, 43), TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-aai-1", exchange_url, - "EUR:5.01", 42, 2), + "EUR:5.01", 42, 2), /** * NOTE: the old test-suite had this "check bank transfer" @@ -439,23 +442,23 @@ run (void *cls, */ TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-aai-2", exchange_url, - "EUR:5.01", 42, 2), + "EUR:5.01", 42, 2), TALER_TESTING_cmd_check_bank_empty ("check_bank_empty"), TALER_TESTING_cmd_track_transaction - ("deposit-wtid-ok", - "deposit-simple", 0, MHD_HTTP_OK, "check_bank_transfer-499c"), + ("deposit-wtid-ok", + "deposit-simple", 0, MHD_HTTP_OK, "check_bank_transfer-499c"), TALER_TESTING_cmd_track_transfer ("wire-deposit-success-bank", - "check_bank_transfer-99c1", 0, MHD_HTTP_OK, "EUR:0.98", - "EUR:0.01"), + "check_bank_transfer-99c1", 0, MHD_HTTP_OK, "EUR:0.98", + "EUR:0.01"), TALER_TESTING_cmd_track_transfer ("wire-deposits-success-wtid", - "deposit-wtid-ok", 0, MHD_HTTP_OK, "EUR:4.98", - "EUR:0.01"), + "deposit-wtid-ok", 0, MHD_HTTP_OK, "EUR:4.98", + "EUR:0.01"), TALER_TESTING_cmd_end () }; @@ -478,30 +481,30 @@ run (void *cls, /* "consume" reserve creation transfer. */ TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-unaggregated", - exchange_url, - "EUR:5.01", - 42, - 2), + exchange_url, + "EUR:5.01", + 42, + 2), TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-unaggregated", - "create-reserve-unaggregated", - "EUR:5", - MHD_HTTP_OK), + "create-reserve-unaggregated", + "EUR:5", + MHD_HTTP_OK), TALER_TESTING_cmd_deposit ("deposit-unaggregated", - "withdraw-coin-unaggregated", - 0, - TALER_TESTING_make_wire_details - (43, - fakebank_url), - "{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}", - GNUNET_TIME_relative_multiply - (GNUNET_TIME_UNIT_YEARS, - 3000), - "EUR:5", - MHD_HTTP_OK), + "withdraw-coin-unaggregated", + 0, + TALER_TESTING_make_wire_details + (43, + fakebank_url), + "{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}", + GNUNET_TIME_relative_multiply + (GNUNET_TIME_UNIT_YEARS, + 3000), + "EUR:5", + MHD_HTTP_OK), CMD_EXEC_AGGREGATOR ("aggregation-attempt"), @@ -538,11 +541,11 @@ run (void *cls, */ TALER_TESTING_cmd_deposit ("deposit-refund-1", "withdraw-coin-r1", 0, - TALER_TESTING_make_wire_details (42, - fakebank_url), - "{\"items\":[{\"name\":\"ice cream\"," - "\"value\":\"EUR:5\"}]}", - GNUNET_TIME_UNIT_MINUTES, "EUR:5", MHD_HTTP_OK), + TALER_TESTING_make_wire_details (42, + fakebank_url), + "{\"items\":[{\"name\":\"ice cream\"," + "\"value\":\"EUR:5\"}]}", + GNUNET_TIME_UNIT_MINUTES, "EUR:5", MHD_HTTP_OK), /** @@ -561,23 +564,23 @@ run (void *cls, TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-pre-refund", exchange_url, - "EUR:5.01", 42, 2), + "EUR:5.01", 42, 2), TALER_TESTING_cmd_check_bank_empty ("check_bank_transfer-pre-refund"), TALER_TESTING_cmd_refund ("refund-ok", MHD_HTTP_OK, - "EUR:5", "EUR:0.01", "deposit-refund-1"), + "EUR:5", "EUR:0.01", "deposit-refund-1"), TALER_TESTING_cmd_refund ("refund-ok-double", MHD_HTTP_OK, - "EUR:5", "EUR:0.01", "deposit-refund-1"), + "EUR:5", "EUR:0.01", "deposit-refund-1"), /* Previous /refund(s) had id == 0. */ TALER_TESTING_cmd_refund_with_id ("refund-conflicting", MHD_HTTP_CONFLICT, - "EUR:5", "EUR:0.01", "deposit-refund-1", 1), + "EUR:5", "EUR:0.01", "deposit-refund-1", 1), /** * Spend 4.99 EUR of the refunded 4.99 EUR coin (1ct gone @@ -585,11 +588,11 @@ run (void *cls, * 1 ct deposit fee) */ TALER_TESTING_cmd_deposit ("deposit-refund-2", "withdraw-coin-r1", 0, - TALER_TESTING_make_wire_details (42, - fakebank_url), - "{\"items\":[{\"name\":\"more ice cream\"," - "\"value\":\"EUR:5\"}]}", - GNUNET_TIME_UNIT_ZERO, "EUR:4.99", MHD_HTTP_OK), + TALER_TESTING_make_wire_details (42, + fakebank_url), + "{\"items\":[{\"name\":\"more ice cream\"," + "\"value\":\"EUR:5\"}]}", + GNUNET_TIME_UNIT_ZERO, "EUR:4.99", MHD_HTTP_OK), /** @@ -603,14 +606,14 @@ run (void *cls, */ TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-pre-refund", exchange_url, - "EUR:4.97", 2, 42), + "EUR:4.97", 2, 42), /** * Run failing refund, as past deadline & aggregation. */ TALER_TESTING_cmd_refund ("refund-fail", MHD_HTTP_GONE, - "EUR:4.99", "EUR:0.01", "deposit-refund-2"), + "EUR:4.99", "EUR:0.01", "deposit-refund-2"), TALER_TESTING_cmd_check_bank_empty ("check-empty-after-refund"), @@ -631,16 +634,16 @@ run (void *cls, TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-aai-3b", exchange_url, - "EUR:5.01", 42, 2), + "EUR:5.01", 42, 2), TALER_TESTING_cmd_deposit ("deposit-refund-1b", "withdraw-coin-rb", 0, - TALER_TESTING_make_wire_details (42, - fakebank_url), - "{\"items\":[{\"name\":\"ice cream\"," - "\"value\":\"EUR:5\"}]}", - GNUNET_TIME_UNIT_ZERO, "EUR:5", MHD_HTTP_OK), + TALER_TESTING_make_wire_details (42, + fakebank_url), + "{\"items\":[{\"name\":\"ice cream\"," + "\"value\":\"EUR:5\"}]}", + GNUNET_TIME_UNIT_ZERO, "EUR:5", MHD_HTTP_OK), /** * Trigger refund (before aggregator had a chance to execute @@ -648,7 +651,7 @@ run (void *cls, */ TALER_TESTING_cmd_refund ("refund-ok-fast", MHD_HTTP_OK, - "EUR:5", "EUR:0.01", "deposit-refund-1b"), + "EUR:5", "EUR:0.01", "deposit-refund-1b"), /** * Run transfers. This will do the transfer as refund deadline @@ -713,9 +716,9 @@ run (void *cls, */ TALER_TESTING_cmd_withdraw_amount ("payback-withdraw-coin-2-over", - "payback-create-reserve-1", - "EUR:10", - MHD_HTTP_FORBIDDEN), + "payback-create-reserve-1", + "EUR:10", + MHD_HTTP_FORBIDDEN), TALER_TESTING_cmd_status ("payback-reserve-status-2", "payback-create-reserve-1", @@ -729,15 +732,15 @@ run (void *cls, */ CMD_TRANSFER_TO_EXCHANGE ("short-lived-reserve", - "EUR:5.01"), + "EUR:5.01"), TALER_TESTING_cmd_exec_wirewatch ("short-lived-aggregation", - CONFIG_FILE_EXPIRE_RESERVE_NOW), + CONFIG_FILE_EXPIRE_RESERVE_NOW), TALER_TESTING_cmd_exec_aggregator ("close-reserves", - CONFIG_FILE_EXPIRE_RESERVE_NOW), + CONFIG_FILE_EXPIRE_RESERVE_NOW), TALER_TESTING_cmd_status ("short-lived-status", "short-lived-reserve", @@ -746,23 +749,23 @@ run (void *cls, TALER_TESTING_cmd_withdraw_amount ("expired-withdraw", - "short-lived-reserve", - "EUR:1", - MHD_HTTP_FORBIDDEN), + "short-lived-reserve", + "EUR:1", + MHD_HTTP_FORBIDDEN), TALER_TESTING_cmd_check_bank_transfer ("check_bank_short-lived_transfer", - exchange_url, - "EUR:5.01", - 42, - 2), + exchange_url, + "EUR:5.01", + 42, + 2), TALER_TESTING_cmd_check_bank_transfer ("check_bank_short-lived_reimburse", - exchange_url, - "EUR:5", - 2, - 42), + exchange_url, + "EUR:5", + 2, + 42), /** * Fill reserve with EUR:2.02, as withdraw fee is 1 ct per @@ -791,11 +794,11 @@ run (void *cls, TALER_TESTING_cmd_deposit ("payback-deposit-partial", - "payback-withdraw-coin-2a", 0, - TALER_TESTING_make_wire_details (42, - fakebank_url), - "{\"items\":[{\"name\":\"more ice cream\",\"value\":1}]}", - GNUNET_TIME_UNIT_ZERO, "EUR:0.5", MHD_HTTP_OK), + "payback-withdraw-coin-2a", 0, + TALER_TESTING_make_wire_details (42, + fakebank_url), + "{\"items\":[{\"name\":\"more ice cream\",\"value\":1}]}", + GNUNET_TIME_UNIT_ZERO, "EUR:0.5", MHD_HTTP_OK), TALER_TESTING_cmd_revoke ("revoke-2", MHD_HTTP_OK, @@ -814,11 +817,11 @@ run (void *cls, TALER_TESTING_cmd_deposit ("payback-deposit-revoked", - "payback-withdraw-coin-2b", 0, - TALER_TESTING_make_wire_details (42, - fakebank_url), - "{\"items\":[{\"name\":\"more ice cream\",\"value\":1}]}", - GNUNET_TIME_UNIT_ZERO, "EUR:1", MHD_HTTP_NOT_FOUND), + "payback-withdraw-coin-2b", 0, + TALER_TESTING_make_wire_details (42, + fakebank_url), + "{\"items\":[{\"name\":\"more ice cream\",\"value\":1}]}", + GNUNET_TIME_UNIT_ZERO, "EUR:1", MHD_HTTP_NOT_FOUND), /* Test deposit fails after payback, with proof in payback */ @@ -828,15 +831,15 @@ run (void *cls, * 404 on the DK! */ TALER_TESTING_cmd_deposit ("payback-deposit-partial-after-payback", - "payback-withdraw-coin-2a", - 0, - TALER_TESTING_make_wire_details - (42, - fakebank_url), - "{\"items\":[{\"name\":\"extra ice cream\",\"value\":1}]}", - GNUNET_TIME_UNIT_ZERO, - "EUR:0.5", - MHD_HTTP_NOT_FOUND), + "payback-withdraw-coin-2a", + 0, + TALER_TESTING_make_wire_details + (42, + fakebank_url), + "{\"items\":[{\"name\":\"extra ice cream\",\"value\":1}]}", + GNUNET_TIME_UNIT_ZERO, + "EUR:0.5", + MHD_HTTP_NOT_FOUND), /* Test that revoked coins cannot be withdrawn */ CMD_TRANSFER_TO_EXCHANGE ("payback-create-reserve-3", @@ -846,20 +849,20 @@ run (void *cls, TALER_TESTING_cmd_withdraw_amount ("payback-withdraw-coin-3-revoked", - "payback-create-reserve-3", - "EUR:1", - MHD_HTTP_NOT_FOUND), + "payback-create-reserve-3", + "EUR:1", + MHD_HTTP_NOT_FOUND), /* check that we are empty before the rejection test */ TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-pr1", exchange_url, - "EUR:5.01", 42, 2), + "EUR:5.01", 42, 2), TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-pr2", exchange_url, - "EUR:2.02", 42, 2), + "EUR:2.02", 42, 2), TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-pr3", exchange_url, - "EUR:1.01", 42, 2), + "EUR:1.01", 42, 2), TALER_TESTING_cmd_check_bank_empty ("check-empty-again"), @@ -867,8 +870,8 @@ run (void *cls, /* Test rejection of bogus wire transfers */ CMD_TRANSFER_TO_EXCHANGE_SUBJECT ("bogus-subject", - "EUR:1.01", - "not a reserve public key"), + "EUR:1.01", + "not a reserve public key"), CMD_EXEC_WIREWATCH ("wirewatch-7"), @@ -881,11 +884,11 @@ run (void *cls, #define RESERVE_OPEN_CLOSE_CHUNK 4 #define RESERVE_OPEN_CLOSE_ITERATIONS 3 #define CONSTANT_KEY \ - "09QGYPEKNHBACK135BNXZFHA0YTQXT1KJDRVXF4J822G99AYNQ8G" + "09QGYPEKNHBACK135BNXZFHA0YTQXT1KJDRVXF4J822G99AYNQ8G" struct TALER_TESTING_Command reserve_open_close - [(RESERVE_OPEN_CLOSE_ITERATIONS - * RESERVE_OPEN_CLOSE_CHUNK) + 1]; + [(RESERVE_OPEN_CLOSE_ITERATIONS + * RESERVE_OPEN_CLOSE_CHUNK) + 1]; for (unsigned int i = 0; i < RESERVE_OPEN_CLOSE_ITERATIONS; @@ -894,18 +897,18 @@ run (void *cls, reserve_open_close[i * RESERVE_OPEN_CLOSE_CHUNK] = CMD_TRANSFER_TO_EXCHANGE_SUBJECT ("reserve-open-close-key", - "EUR:20", - CONSTANT_KEY); + "EUR:20", + CONSTANT_KEY); reserve_open_close[(i * RESERVE_OPEN_CLOSE_CHUNK) + 1] = TALER_TESTING_cmd_exec_wirewatch ("reserve-open-close-wirewatch", - CONFIG_FILE_EXPIRE_RESERVE_NOW); + CONFIG_FILE_EXPIRE_RESERVE_NOW); reserve_open_close[(i * RESERVE_OPEN_CLOSE_CHUNK) + 2] = TALER_TESTING_cmd_exec_aggregator ("reserve-open-close-aggregation", - CONFIG_FILE_EXPIRE_RESERVE_NOW); + CONFIG_FILE_EXPIRE_RESERVE_NOW); reserve_open_close[(i * RESERVE_OPEN_CLOSE_CHUNK) + 3] = TALER_TESTING_cmd_status ("reserve-open-close-status", @@ -914,8 +917,8 @@ run (void *cls, MHD_HTTP_OK); } reserve_open_close - [RESERVE_OPEN_CLOSE_ITERATIONS * RESERVE_OPEN_CLOSE_CHUNK] - = TALER_TESTING_cmd_end (); + [RESERVE_OPEN_CLOSE_ITERATIONS * RESERVE_OPEN_CLOSE_CHUNK] + = TALER_TESTING_cmd_end (); struct TALER_TESTING_Command commands[] = { @@ -960,7 +963,7 @@ run (void *cls, int main (int argc, - char * const *argv) + char *const *argv) { /* These environment variables get in the way... */ unsetenv ("XDG_DATA_HOME"); @@ -969,10 +972,10 @@ main (int argc, "INFO", NULL); if (NULL == (fakebank_url - /* Check fakebank port is available and config cares - * about bank url. */ - = TALER_TESTING_prepare_fakebank (CONFIG_FILE, - "account-2"))) + /* Check fakebank port is available and config cares + * about bank url. */ + = TALER_TESTING_prepare_fakebank (CONFIG_FILE, + "account-2"))) return 77; TALER_TESTING_cleanup_files (CONFIG_FILE); /* @helpers. Run keyup, create tables, ... Note: it diff --git a/src/lib/test_exchange_api_interpreter_on-off.c b/src/lib/test_exchange_api_interpreter_on-off.c index ee49dd45e..40094ad4b 100644 --- a/src/lib/test_exchange_api_interpreter_on-off.c +++ b/src/lib/test_exchange_api_interpreter_on-off.c @@ -40,7 +40,7 @@ * * This test helps in finding a way to use/modify the "normal" * cert_cb to handle reconnections from serialized states as well. - * + * * 1st step: simply turn the interpreter off and on again. * 2nd step: turn the interpreter off and give a serial state * to reconnect. @@ -80,13 +80,13 @@ run (void *cls, }; TALER_TESTING_run (is, - commands); + commands); } int main (int argc, - char * const *argv) + char *const *argv) { /* These environment variables get in the way... */ unsetenv ("XDG_DATA_HOME"); @@ -99,7 +99,7 @@ main (int argc, * if it's available. */ switch (TALER_TESTING_prepare_exchange (CONFIG_FILE, &auditor_url, - &exchange_url)) + &exchange_url)) { case GNUNET_SYSERR: GNUNET_break (0); diff --git a/src/lib/test_exchange_api_keys_cherry_picking.c b/src/lib/test_exchange_api_keys_cherry_picking.c index 97fa5a268..3acc27536 100644 --- a/src/lib/test_exchange_api_keys_cherry_picking.c +++ b/src/lib/test_exchange_api_keys_cherry_picking.c @@ -65,8 +65,8 @@ #define ADDSECS(base, secs) \ GNUNET_TIME_absolute_add \ (base, \ - GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, \ - secs)) + GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, \ + secs)) /** * Subtract seconds. @@ -78,8 +78,8 @@ #define SUBSECS(base, secs) \ GNUNET_TIME_absolute_subtract \ (base, \ - GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, \ - secs)) + GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, \ + secs)) #define JAN1971 "1971-01-01" #define JAN2030 "2030-01-01" @@ -128,28 +128,28 @@ run (void *cls, ("serialize-keys"), TALER_TESTING_cmd_connect_with_state ("reconnect-with-state", - "serialize-keys"), + "serialize-keys"), /** * Make sure we have the same keys situation as * it was before the serialization. */ TALER_TESTING_cmd_check_keys_with_now ("check-keys-after-deserialization", - 4, - NDKS_RIGHT_BEFORE_SERIALIZATION, - /** - * Pretend 5 seconds passed. - */ - ADDSECS (TTH_parse_time (JAN2030), - 5)), + 4, + NDKS_RIGHT_BEFORE_SERIALIZATION, + /** + * Pretend 5 seconds passed. + */ + ADDSECS (TTH_parse_time (JAN2030), + 5)), /** * Use one of the deserialized keys. */ TALER_TESTING_cmd_wire ("verify-/wire-with-serialized-keys", - "x-taler-bank", - NULL, - MHD_HTTP_OK), + "x-taler-bank", + NULL, + MHD_HTTP_OK), TALER_TESTING_cmd_end (), }; @@ -169,26 +169,26 @@ run (void *cls, */ TALER_TESTING_cmd_exec_keyup_with_now ("keyup-1", - CONFIG_FILE, - TTH_parse_time (JAN2030)), - /** - * Should return 1 new key, + the original one. NOTE: the - * original DK will never be 'cancelled' as for the current - * libtalerexchange logic, so it must always be counted. - */ + CONFIG_FILE, + TTH_parse_time (JAN2030)), + /** + * Should return 1 new key, + the original one. NOTE: the + * original DK will never be 'cancelled' as for the current + * libtalerexchange logic, so it must always be counted. + */ TALER_TESTING_cmd_check_keys_with_now ("check-keys-2", - 2, /* generation */ - 2, - TTH_parse_time (JAN2030)), + 2, /* generation */ + 2, + TTH_parse_time (JAN2030)), TALER_TESTING_cmd_exec_keyup_with_now ("keyup-3", - CONFIG_FILE_EXTENDED_2, - /* Taking care of not using a 'now' that equals the - * last DK timestamp, otherwise it would get silently - * overridden. */ - ADDSECS (TTH_parse_time (JAN2030), - 10)), + CONFIG_FILE_EXTENDED_2, + /* Taking care of not using a 'now' that equals the + * last DK timestamp, otherwise it would get silently + * overridden. */ + ADDSECS (TTH_parse_time (JAN2030), + 10)), /** * Expected number of DK: @@ -208,9 +208,9 @@ run (void *cls, TALER_TESTING_cmd_check_keys_with_now ("check-keys-3", - 3, - NDKS_RIGHT_BEFORE_SERIALIZATION, - TTH_parse_time (JAN2030)), + 3, + NDKS_RIGHT_BEFORE_SERIALIZATION, + TTH_parse_time (JAN2030)), TALER_TESTING_cmd_end () }; @@ -230,7 +230,7 @@ run (void *cls, int main (int argc, - char * const *argv) + char *const *argv) { /* These environment variables get in the way... */ unsetenv ("XDG_DATA_HOME"); diff --git a/src/lib/test_exchange_api_overlapping_keys_bug.c b/src/lib/test_exchange_api_overlapping_keys_bug.c index 7b1458447..6680fbbc9 100644 --- a/src/lib/test_exchange_api_overlapping_keys_bug.c +++ b/src/lib/test_exchange_api_overlapping_keys_bug.c @@ -94,7 +94,7 @@ run (void *cls, int main (int argc, - char * const *argv) + char *const *argv) { /* These environment variables get in the way... */ unsetenv ("XDG_DATA_HOME"); diff --git a/src/lib/test_exchange_api_revocation.c b/src/lib/test_exchange_api_revocation.c index 14bb4553f..c0c96766c 100644 --- a/src/lib/test_exchange_api_revocation.c +++ b/src/lib/test_exchange_api_revocation.c @@ -88,7 +88,7 @@ static char *auditor_url; * @param label label to use for the command. */ #define CMD_EXEC_WIREWATCH(label) \ - TALER_TESTING_cmd_exec_wirewatch (label, CONFIG_FILE) + TALER_TESTING_cmd_exec_wirewatch (label, CONFIG_FILE) /** * Run wire transfer of funds from some user's account to the @@ -98,9 +98,11 @@ static char *auditor_url; * @param amount amount to transfer, i.e. "EUR:1" */ #define CMD_TRANSFER_TO_EXCHANGE(label,amount) \ - TALER_TESTING_cmd_fakebank_transfer (label, amount, \ - fakebank_url, USER_ACCOUNT_NO, EXCHANGE_ACCOUNT_NO, \ - USER_LOGIN_NAME, USER_LOGIN_PASS, exchange_url) + TALER_TESTING_cmd_fakebank_transfer (label, amount, \ + fakebank_url, USER_ACCOUNT_NO, \ + EXCHANGE_ACCOUNT_NO, \ + USER_LOGIN_NAME, USER_LOGIN_PASS, \ + exchange_url) /** * Main function that will tell the interpreter what commands to @@ -135,26 +137,26 @@ run (void *cls, */ TALER_TESTING_cmd_deposit ("deposit-partial", - "withdraw-coin-1", 0, - TALER_TESTING_make_wire_details (42, - fakebank_url), - "{\"items\":[{\"name\":\"ice cream\",\ + "withdraw-coin-1", 0, + TALER_TESTING_make_wire_details (42, + fakebank_url), + "{\"items\":[{\"name\":\"ice cream\",\ \"value\":\"EUR:1\"}]}", - GNUNET_TIME_UNIT_ZERO, "EUR:1", MHD_HTTP_OK), + GNUNET_TIME_UNIT_ZERO, "EUR:1", MHD_HTTP_OK), /** * Melt SOME of the rest of the coin's value * (EUR:3.17 = 3x EUR:1.03 + 7x EUR:0.13) */ TALER_TESTING_cmd_refresh_melt ("refresh-melt-1", - "withdraw-coin-1", - MHD_HTTP_OK, - NULL), + "withdraw-coin-1", + MHD_HTTP_OK, + NULL), /** * Complete (successful) melt operation, and withdraw the coins */ TALER_TESTING_cmd_refresh_reveal ("refresh-reveal-1", - "refresh-melt-1", MHD_HTTP_OK), + "refresh-melt-1", MHD_HTTP_OK), /* Make refreshed coin invalid */ TALER_TESTING_cmd_revoke ("revoke-1", MHD_HTTP_OK, @@ -182,16 +184,16 @@ run (void *cls, leaving EUR:3.69. */ TALER_TESTING_cmd_refresh_melt ("refresh-melt-2", - "withdraw-coin-1", - MHD_HTTP_OK, - "EUR:0.1", - NULL), + "withdraw-coin-1", + MHD_HTTP_OK, + "EUR:0.1", + NULL), /** * Complete (successful) melt operation, and withdraw the coins */ TALER_TESTING_cmd_refresh_reveal ("refresh-reveal-2", - "refresh-melt-2", MHD_HTTP_OK), + "refresh-melt-2", MHD_HTTP_OK), /* Revokes refreshed EUR:0.1 coin */ TALER_TESTING_cmd_revoke ("revoke-2", MHD_HTTP_OK, @@ -231,7 +233,7 @@ run (void *cls, int main (int argc, - char * const *argv) + char *const *argv) { /* These environment variables get in the way... */ unsetenv ("XDG_DATA_HOME"); @@ -240,10 +242,10 @@ main (int argc, "INFO", NULL); if (NULL == (fakebank_url - /* Check fakebank port is available and config cares - * about bank url. */ - = TALER_TESTING_prepare_fakebank (CONFIG_FILE, - "account-2"))) + /* Check fakebank port is available and config cares + * about bank url. */ + = TALER_TESTING_prepare_fakebank (CONFIG_FILE, + "account-2"))) return 77; TALER_TESTING_cleanup_files (CONFIG_FILE); /* @helpers. Run keyup, create tables, ... Note: it diff --git a/src/lib/test_exchange_api_twisted.c b/src/lib/test_exchange_api_twisted.c index 48a4ed36e..52c928341 100644 --- a/src/lib/test_exchange_api_twisted.c +++ b/src/lib/test_exchange_api_twisted.c @@ -97,7 +97,7 @@ static struct GNUNET_OS_Process *twisterd; * @param label label to use for the command. */ #define CMD_EXEC_WIREWATCH(label) \ - TALER_TESTING_cmd_exec_wirewatch (label, CONFIG_FILE) + TALER_TESTING_cmd_exec_wirewatch (label, CONFIG_FILE) /** * Execute the taler-exchange-aggregator command with @@ -106,7 +106,7 @@ static struct GNUNET_OS_Process *twisterd; * @param label label to use for the command. */ #define CMD_EXEC_AGGREGATOR(label) \ - TALER_TESTING_cmd_exec_aggregator (label, CONFIG_FILE) + TALER_TESTING_cmd_exec_aggregator (label, CONFIG_FILE) /** * Run wire transfer of funds from some user's account to the @@ -117,9 +117,11 @@ static struct GNUNET_OS_Process *twisterd; * @param url exchange_url */ #define CMD_TRANSFER_TO_EXCHANGE(label,amount) \ - TALER_TESTING_cmd_fakebank_transfer (label, amount, \ - fakebank_url, USER_ACCOUNT_NO, EXCHANGE_ACCOUNT_NO, \ - USER_LOGIN_NAME, USER_LOGIN_PASS, exchange_url) + TALER_TESTING_cmd_fakebank_transfer (label, amount, \ + fakebank_url, USER_ACCOUNT_NO, \ + EXCHANGE_ACCOUNT_NO, \ + USER_LOGIN_NAME, USER_LOGIN_PASS, \ + exchange_url) /** * Run wire transfer of funds from some user's account to the @@ -129,10 +131,10 @@ static struct GNUNET_OS_Process *twisterd; * @param amount amount to transfer, i.e. "EUR:1" */ #define CMD_TRANSFER_TO_EXCHANGE_SUBJECT(label,amount,subject) \ - TALER_TESTING_cmd_fakebank_transfer_with_subject \ - (label, amount, fakebank_url, USER_ACCOUNT_NO, \ - EXCHANGE_ACCOUNT_NO, USER_LOGIN_NAME, USER_LOGIN_PASS, \ - subject) + TALER_TESTING_cmd_fakebank_transfer_with_subject \ + (label, amount, fakebank_url, USER_ACCOUNT_NO, \ + EXCHANGE_ACCOUNT_NO, USER_LOGIN_NAME, USER_LOGIN_PASS, \ + subject) /** * Main function that will tell the interpreter what commands to @@ -152,7 +154,7 @@ run (void *cls, CMD_TRANSFER_TO_EXCHANGE ("refresh-create-reserve", - "EUR:5.01"), + "EUR:5.01"), /** * Make previous command effective. @@ -165,42 +167,42 @@ run (void *cls, */ TALER_TESTING_cmd_withdraw_amount ("refresh-withdraw-coin", - "refresh-create-reserve", - "EUR:5", - MHD_HTTP_OK), + "refresh-create-reserve", + "EUR:5", + MHD_HTTP_OK), TALER_TESTING_cmd_deposit ("refresh-deposit-partial", - "refresh-withdraw-coin", - 0, - TALER_TESTING_make_wire_details - (42, - fakebank_url), - "{\"items\":[{\"name\":\"ice cream\",\ + "refresh-withdraw-coin", + 0, + TALER_TESTING_make_wire_details + (42, + fakebank_url), + "{\"items\":[{\"name\":\"ice cream\",\ \"value\":\"EUR:1\"}]}", - GNUNET_TIME_UNIT_ZERO, - "EUR:1", - MHD_HTTP_OK), + GNUNET_TIME_UNIT_ZERO, + "EUR:1", + MHD_HTTP_OK), /** * Melt the rest of the coin's value * (EUR:4.00 = 3x EUR:1.03 + 7x EUR:0.13) */ TALER_TESTING_cmd_refresh_melt ("refresh-melt", - "refresh-withdraw-coin", - MHD_HTTP_OK, - NULL), + "refresh-withdraw-coin", + MHD_HTTP_OK, + NULL), /* Trigger 409 Conflict. */ TALER_TESTING_cmd_flip_upload ("flip-upload", - CONFIG_FILE, - "transfer_privs.0"), + CONFIG_FILE, + "transfer_privs.0"), TALER_TESTING_cmd_refresh_reveal ("refresh-(flipped-)reveal", - "refresh-melt", - MHD_HTTP_CONFLICT), + "refresh-melt", + MHD_HTTP_CONFLICT), TALER_TESTING_cmd_end () @@ -216,55 +218,55 @@ run (void *cls, CMD_TRANSFER_TO_EXCHANGE ("create-reserve-r1", - "EUR:5.01"), + "EUR:5.01"), CMD_EXEC_WIREWATCH ("wirewatch-r1"), TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-r1", - "create-reserve-r1", - "EUR:5", - MHD_HTTP_OK), + "create-reserve-r1", + "EUR:5", + MHD_HTTP_OK), TALER_TESTING_cmd_deposit ("deposit-refund-1", - "withdraw-coin-r1", - 0, - TALER_TESTING_make_wire_details - (42, - fakebank_url), - "{\"items\":[{\"name\":\"ice cream\"," - "\"value\":\"EUR:5\"}]}", - GNUNET_TIME_UNIT_MINUTES, - "EUR:5", - MHD_HTTP_OK), + "withdraw-coin-r1", + 0, + TALER_TESTING_make_wire_details + (42, + fakebank_url), + "{\"items\":[{\"name\":\"ice cream\"," + "\"value\":\"EUR:5\"}]}", + GNUNET_TIME_UNIT_MINUTES, + "EUR:5", + MHD_HTTP_OK), TALER_TESTING_cmd_refund ("refund-currency-missmatch", - MHD_HTTP_PRECONDITION_FAILED, - "USD:5", - "USD:0.01", - "deposit-refund-1"), + MHD_HTTP_PRECONDITION_FAILED, + "USD:5", + "USD:0.01", + "deposit-refund-1"), TALER_TESTING_cmd_refund ("refund-fee-above-amount", - MHD_HTTP_BAD_REQUEST, - "EUR:5", - "EUR:10", - "deposit-refund-1"), + MHD_HTTP_BAD_REQUEST, + "EUR:5", + "EUR:10", + "deposit-refund-1"), TALER_TESTING_cmd_flip_upload ("flip-upload", - CONFIG_FILE, - "merchant_sig"), + CONFIG_FILE, + "merchant_sig"), TALER_TESTING_cmd_refund ("refund-bad-sig", - MHD_HTTP_UNAUTHORIZED, - "EUR:5", - "EUR:0.01", - "deposit-refund-1"), + MHD_HTTP_UNAUTHORIZED, + "EUR:5", + "EUR:0.01", + "deposit-refund-1"), /* This next deposit CMD is only used to provide a * good merchant signature to the next (failing) refund @@ -272,40 +274,40 @@ run (void *cls, TALER_TESTING_cmd_deposit ("deposit-refund-to-fail", - "withdraw-coin-r1", - 0, /* coin index. */ - TALER_TESTING_make_wire_details - (42, - fakebank_url), - /* This parameter will make any comparison about - h_contract_terms fail, when /refund will be handled. - So in other words, this is h_contract missmatch. */ - "{\"items\":[{\"name\":\"ice skate\"," - "\"value\":\"EUR:5\"}]}", - GNUNET_TIME_UNIT_MINUTES, - "EUR:5", - MHD_HTTP_FORBIDDEN), + "withdraw-coin-r1", + 0, /* coin index. */ + TALER_TESTING_make_wire_details + (42, + fakebank_url), + /* This parameter will make any comparison about + h_contract_terms fail, when /refund will be handled. + So in other words, this is h_contract missmatch. */ + "{\"items\":[{\"name\":\"ice skate\"," + "\"value\":\"EUR:5\"}]}", + GNUNET_TIME_UNIT_MINUTES, + "EUR:5", + MHD_HTTP_FORBIDDEN), TALER_TESTING_cmd_refund ("refund-deposit-not-found", - MHD_HTTP_NOT_FOUND, - "EUR:5", - "EUR:0.01", - "deposit-refund-to-fail"), + MHD_HTTP_NOT_FOUND, + "EUR:5", + "EUR:0.01", + "deposit-refund-to-fail"), TALER_TESTING_cmd_refund ("refund-insufficient-funds", - MHD_HTTP_PRECONDITION_FAILED, - "EUR:50", - "EUR:0.01", - "deposit-refund-1"), + MHD_HTTP_PRECONDITION_FAILED, + "EUR:50", + "EUR:0.01", + "deposit-refund-1"), TALER_TESTING_cmd_refund ("refund-fee-too-low", - MHD_HTTP_BAD_REQUEST, - "EUR:5", - "EUR:0.000001", - "deposit-refund-1"), + MHD_HTTP_BAD_REQUEST, + "EUR:5", + "EUR:0.000001", + "deposit-refund-1"), TALER_TESTING_cmd_end () }; @@ -341,7 +343,7 @@ purge_process (struct GNUNET_OS_Process *process) int main (int argc, - char * const *argv) + char *const *argv) { unsigned int ret; /* These environment variables get in the way... */ @@ -351,12 +353,12 @@ main (int argc, "DEBUG", NULL); if (NULL == (fakebank_url = TALER_TESTING_prepare_fakebank - (CONFIG_FILE, - "account-2"))) + (CONFIG_FILE, + "account-2"))) return 77; if (NULL == (twister_url = TALER_TESTING_prepare_twister - (CONFIG_FILE))) + (CONFIG_FILE))) return 77; TALER_TESTING_cleanup_files (CONFIG_FILE); @@ -374,7 +376,7 @@ main (int argc, case GNUNET_OK: if (NULL == (twisterd = TALER_TESTING_run_twister - (CONFIG_FILE))) + (CONFIG_FILE))) return 77; ret = TALER_TESTING_setup_with_exchange (&run, diff --git a/src/lib/testing_api_cmd_bank_check.c b/src/lib/testing_api_cmd_bank_check.c index 67dbc0e19..0006b6e5e 100644 --- a/src/lib/testing_api_cmd_bank_check.c +++ b/src/lib/testing_api_cmd_bank_check.c @@ -53,7 +53,7 @@ struct BankCheckState * Expected debit bank account. */ uint64_t debit_account; - + /** * Expected credit bank account. */ @@ -133,7 +133,7 @@ check_bank_transfer_run (void *cls, bcs->deposit_reference, bcs->deposit_reference); deposit_cmd = TALER_TESTING_interpreter_lookup_command - (is, bcs->deposit_reference); + (is, bcs->deposit_reference); if (NULL == deposit_cmd) TALER_TESTING_FAIL (is); @@ -181,10 +181,10 @@ check_bank_transfer_run (void *cls, static void check_bank_transfer_cleanup (void *cls, - const struct TALER_TESTING_Command *cmd) + const struct TALER_TESTING_Command *cmd) { struct BankCheckState *bcs = cls; - + GNUNET_free_non_null (bcs->subject); GNUNET_free (bcs); } @@ -204,14 +204,14 @@ check_bank_transfer_traits (void *cls, const char *trait, unsigned int index) { - struct BankCheckState *bcs = cls; + struct BankCheckState *bcs = cls; struct TALER_WireTransferIdentifierRawP *wtid_ptr; if (GNUNET_OK != GNUNET_STRINGS_string_to_data - (bcs->subject, - strlen (bcs->subject), - &bcs->wtid, - sizeof (struct TALER_WireTransferIdentifierRawP))) + (bcs->subject, + strlen (bcs->subject), + &bcs->wtid, + sizeof (struct TALER_WireTransferIdentifierRawP))) wtid_ptr = NULL; else wtid_ptr = &bcs->wtid; @@ -227,7 +227,7 @@ check_bank_transfer_traits (void *cls, ret, trait, index); -} +} @@ -247,10 +247,10 @@ check_bank_transfer_traits (void *cls, struct TALER_TESTING_Command TALER_TESTING_cmd_check_bank_transfer (const char *label, - const char *exchange_base_url, - const char *amount, - uint64_t debit_account, - uint64_t credit_account) + const char *exchange_base_url, + const char *amount, + uint64_t debit_account, + uint64_t credit_account) { struct BankCheckState *bcs; @@ -282,7 +282,7 @@ TALER_TESTING_cmd_check_bank_transfer static void check_bank_empty_cleanup (void *cls, - const struct TALER_TESTING_Command *cmd) + const struct TALER_TESTING_Command *cmd) { return; } @@ -304,7 +304,7 @@ check_bank_empty_run (void *cls, { GNUNET_break (0); TALER_TESTING_interpreter_fail (is); - return; + return; } TALER_TESTING_interpreter_next (is); } @@ -321,7 +321,7 @@ check_bank_empty_traits (void *cls, unsigned int index) { return GNUNET_SYSERR; -} +} /** @@ -342,7 +342,7 @@ TALER_TESTING_cmd_check_bank_empty (const char *label) .cleanup = &check_bank_empty_cleanup, .traits = &check_bank_empty_traits }; - + return cmd; } @@ -361,7 +361,7 @@ TALER_TESTING_cmd_check_bank_empty (const char *label) struct TALER_TESTING_Command TALER_TESTING_cmd_check_bank_transfer_with_ref (const char *label, - const char *deposit_reference) + const char *deposit_reference) { struct BankCheckState *bcs; diff --git a/src/lib/testing_api_cmd_batch.c b/src/lib/testing_api_cmd_batch.c index b1a6a3e01..f5fbc8117 100644 --- a/src/lib/testing_api_cmd_batch.c +++ b/src/lib/testing_api_cmd_batch.c @@ -91,7 +91,7 @@ batch_cleanup (void *cls, { struct BatchState *bs = cls; - for (unsigned int i=0; + for (unsigned int i = 0; NULL != bs->batch[i].label; i++) bs->batch[i].cleanup (bs->batch[i].cls, @@ -158,7 +158,7 @@ TALER_TESTING_cmd_batch (const char *label, bs = GNUNET_new (struct BatchState); /* Get number of commands. */ - for (i=0;NULL != batch[i].label;i++) + for (i = 0; NULL != batch[i].label; i++) /* noop */ ; diff --git a/src/lib/testing_api_cmd_check_keys.c b/src/lib/testing_api_cmd_check_keys.c index ff9647ad8..a0b61c1b0 100644 --- a/src/lib/testing_api_cmd_check_keys.c +++ b/src/lib/testing_api_cmd_check_keys.c @@ -116,12 +116,12 @@ check_keys_run (void *cls, GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Triggering GET /keys, cmd `%s'\n", cmd->label); - + if (GNUNET_YES == cks->set_last_denom) { TALER_LOG_DEBUG ("Forcing last_denom_date URL argument\n"); TALER_EXCHANGE_set_last_denom (is->exchange, - cks->last_denom_date); + cks->last_denom_date); } if (GNUNET_YES == cks->with_now) @@ -131,8 +131,8 @@ check_keys_run (void *cls, GNUNET_break (0 == TALER_EXCHANGE_check_keys_current (is->exchange, - GNUNET_YES, - cks->pull_all_keys).abs_value_us); + GNUNET_YES, + cks->pull_all_keys).abs_value_us); return; } @@ -215,9 +215,9 @@ check_keys_cleanup (void *cls, struct TALER_TESTING_Command TALER_TESTING_cmd_check_keys_with_last_denom (const char *label, - unsigned int generation, - unsigned int num_denom_keys, - struct GNUNET_TIME_Absolute last_denom_date) + unsigned int generation, + unsigned int num_denom_keys, + struct GNUNET_TIME_Absolute last_denom_date) { struct CheckKeysState *cks; @@ -256,8 +256,8 @@ TALER_TESTING_cmd_check_keys_with_last_denom struct TALER_TESTING_Command TALER_TESTING_cmd_check_keys (const char *label, - unsigned int generation, - unsigned int num_denom_keys) + unsigned int generation, + unsigned int num_denom_keys) { struct CheckKeysState *cks; @@ -295,9 +295,9 @@ TALER_TESTING_cmd_check_keys struct TALER_TESTING_Command TALER_TESTING_cmd_check_keys_with_now (const char *label, - unsigned int generation, - unsigned int num_denom_keys, - struct GNUNET_TIME_Absolute now) + unsigned int generation, + unsigned int num_denom_keys, + struct GNUNET_TIME_Absolute now) { struct CheckKeysState *cks; @@ -341,8 +341,8 @@ TALER_TESTING_cmd_check_keys_with_now struct TALER_TESTING_Command TALER_TESTING_cmd_check_keys_pull_all_keys (const char *label, - unsigned int generation, - unsigned int num_denom_keys) + unsigned int generation, + unsigned int num_denom_keys) { struct CheckKeysState *cks; diff --git a/src/lib/testing_api_cmd_deposit.c b/src/lib/testing_api_cmd_deposit.c index d6e3ef548..84fba8f31 100644 --- a/src/lib/testing_api_cmd_deposit.c +++ b/src/lib/testing_api_cmd_deposit.c @@ -191,21 +191,21 @@ deposit_cb (void *cls, { if ( (0 == http_status) || (TALER_EC_DB_COMMIT_FAILED_ON_RETRY == ec) || - (MHD_HTTP_INTERNAL_SERVER_ERROR == http_status) ) + (MHD_HTTP_INTERNAL_SERVER_ERROR == http_status) ) { GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Retrying deposit failed with %u/%d\n", http_status, (int) ec); - /* on DB conflicts, do not use backoff */ - if (TALER_EC_DB_COMMIT_FAILED_ON_RETRY == ec) - ds->backoff = GNUNET_TIME_UNIT_ZERO; - else - ds->backoff = EXCHANGE_LIB_BACKOFF (ds->backoff); - ds->retry_task - = GNUNET_SCHEDULER_add_delayed (ds->backoff, - &do_retry, - ds); + /* on DB conflicts, do not use backoff */ + if (TALER_EC_DB_COMMIT_FAILED_ON_RETRY == ec) + ds->backoff = GNUNET_TIME_UNIT_ZERO; + else + ds->backoff = EXCHANGE_LIB_BACKOFF (ds->backoff); + ds->retry_task + = GNUNET_SCHEDULER_add_delayed (ds->backoff, + &do_retry, + ds); return; } } @@ -260,8 +260,8 @@ deposit_run (void *cls, GNUNET_assert (ds->coin_reference); coin_cmd = TALER_TESTING_interpreter_lookup_command - (is, - ds->coin_reference); + (is, + ds->coin_reference); if (NULL == coin_cmd) { GNUNET_break (0); @@ -274,26 +274,26 @@ deposit_run (void *cls, GNUNET_assert (NULL != coin_cmd); GNUNET_assert (GNUNET_OK - == TALER_TESTING_get_trait_coin_priv (coin_cmd, - ds->coin_index, - &coin_priv)); + == TALER_TESTING_get_trait_coin_priv (coin_cmd, + ds->coin_index, + &coin_priv)); GNUNET_assert (GNUNET_OK - == TALER_TESTING_get_trait_denom_pub (coin_cmd, - ds->coin_index, - &denom_pub)); + == TALER_TESTING_get_trait_denom_pub (coin_cmd, + ds->coin_index, + &denom_pub)); GNUNET_assert (GNUNET_OK - == TALER_TESTING_get_trait_denom_sig (coin_cmd, - ds->coin_index, - &denom_pub_sig)); + == TALER_TESTING_get_trait_denom_sig (coin_cmd, + ds->coin_index, + &denom_pub_sig)); if (GNUNET_OK != TALER_string_to_amount (ds->amount, &amount)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to parse amount `%s' at '%u/%s'\n", - ds->amount, is->ip, this_cmd->label); + ds->amount, is->ip, this_cmd->label); TALER_TESTING_interpreter_fail (is); return; } @@ -315,17 +315,17 @@ deposit_run (void *cls, refund_deadline = GNUNET_TIME_absolute_get_remaining (ds->refund_deadline); wire_deadline = GNUNET_TIME_relative_to_absolute - (GNUNET_TIME_relative_multiply (refund_deadline, 2)); + (GNUNET_TIME_relative_multiply (refund_deadline, 2)); } else { ds->refund_deadline = ds->timestamp; wire_deadline = GNUNET_TIME_relative_to_absolute - (GNUNET_TIME_UNIT_ZERO); + (GNUNET_TIME_UNIT_ZERO); } GNUNET_CRYPTO_eddsa_key_get_public (&ds->merchant_priv.eddsa_priv, - &merchant_pub.eddsa_pub); + &merchant_pub.eddsa_pub); (void) GNUNET_TIME_round_abs (&wire_deadline); @@ -334,42 +334,42 @@ deposit_run (void *cls, memset (&dr, 0, sizeof (dr)); dr.purpose.size = htonl - (sizeof (struct TALER_DepositRequestPS)); + (sizeof (struct TALER_DepositRequestPS)); dr.purpose.purpose = htonl - (TALER_SIGNATURE_WALLET_COIN_DEPOSIT); + (TALER_SIGNATURE_WALLET_COIN_DEPOSIT); dr.h_contract_terms = h_contract_terms; GNUNET_assert (GNUNET_OK == - TALER_JSON_merchant_wire_signature_hash (ds->wire_details, - &dr.h_wire)); + TALER_JSON_merchant_wire_signature_hash (ds->wire_details, + &dr.h_wire)); dr.timestamp = GNUNET_TIME_absolute_hton (ds->timestamp); dr.refund_deadline = GNUNET_TIME_absolute_hton - (ds->refund_deadline); + (ds->refund_deadline); TALER_amount_hton (&dr.amount_with_fee, &amount); TALER_amount_hton (&dr.deposit_fee, &denom_pub->fee_deposit); dr.merchant = merchant_pub; dr.coin_pub = coin_pub; GNUNET_assert (GNUNET_OK == GNUNET_CRYPTO_eddsa_sign - (&coin_priv->eddsa_priv, - &dr.purpose, - &coin_sig.eddsa_signature)); + (&coin_priv->eddsa_priv, + &dr.purpose, + &coin_sig.eddsa_signature)); } ds->dh = TALER_EXCHANGE_deposit - (is->exchange, - &amount, - wire_deadline, - ds->wire_details, - &h_contract_terms, - &coin_pub, - denom_pub_sig, - &denom_pub->key, - ds->timestamp, - &merchant_pub, - ds->refund_deadline, - &coin_sig, - &deposit_cb, - ds); + (is->exchange, + &amount, + wire_deadline, + ds->wire_details, + &h_contract_terms, + &coin_pub, + denom_pub_sig, + &denom_pub->key, + ds->timestamp, + &merchant_pub, + ds->refund_deadline, + &coin_sig, + &deposit_cb, + ds); if (NULL == ds->dh) { @@ -436,8 +436,8 @@ deposit_traits (void *cls, const struct TALER_CoinSpendPrivateKeyP *coin_spent_priv; coin_cmd = TALER_TESTING_interpreter_lookup_command - (ds->is, - ds->coin_reference); + (ds->is, + ds->coin_reference); if (NULL == coin_cmd) { @@ -510,13 +510,13 @@ deposit_traits (void *cls, struct TALER_TESTING_Command TALER_TESTING_cmd_deposit (const char *label, - const char *coin_reference, - unsigned int coin_index, - json_t *wire_details, - const char *contract_terms, - struct GNUNET_TIME_Relative refund_deadline, - const char *amount, - unsigned int expected_response_code) + const char *coin_reference, + unsigned int coin_index, + json_t *wire_details, + const char *contract_terms, + struct GNUNET_TIME_Relative refund_deadline, + const char *amount, + unsigned int expected_response_code) { struct DepositState *ds; @@ -531,9 +531,9 @@ TALER_TESTING_cmd_deposit { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Failed to parse contract terms `%s' for CMD `%s'\n", - contract_terms, - label); + "Failed to parse contract terms `%s' for CMD `%s'\n", + contract_terms, + label); GNUNET_assert (0); } ds->timestamp = GNUNET_TIME_absolute_get (); diff --git a/src/lib/testing_api_cmd_exec_auditor-sign.c b/src/lib/testing_api_cmd_exec_auditor-sign.c index db58b44c9..1a722ad2f 100644 --- a/src/lib/testing_api_cmd_exec_auditor-sign.c +++ b/src/lib/testing_api_cmd_exec_auditor-sign.c @@ -74,7 +74,7 @@ auditor_sign_run (void *cls, cfg = GNUNET_CONFIGURATION_create (); if (GNUNET_OK != GNUNET_CONFIGURATION_load - (cfg, ass->config_filename)) + (cfg, ass->config_filename)) { GNUNET_break (0); TALER_TESTING_interpreter_fail (is); @@ -99,9 +99,9 @@ auditor_sign_run (void *cls, now = GNUNET_TIME_absolute_get (); GNUNET_asprintf (&ass->signed_keys_out, - "%s/.local/share/taler/auditors/auditor-%llu.out", - test_home_dir, - (unsigned long long) now.abs_value_us); + "%s/.local/share/taler/auditors/auditor-%llu.out", + test_home_dir, + (unsigned long long) now.abs_value_us); GNUNET_free (test_home_dir); if (GNUNET_OK != @@ -123,17 +123,17 @@ auditor_sign_run (void *cls, GNUNET_CONFIGURATION_destroy (cfg); ass->auditor_sign_proc = GNUNET_OS_start_process - (GNUNET_NO, - GNUNET_OS_INHERIT_STD_ALL, - NULL, NULL, NULL, - "taler-auditor-sign", - "taler-auditor-sign", - "-c", ass->config_filename, - "-u", "http://auditor/", - "-m", exchange_master_pub, - "-r", "auditor.in", - "-o", ass->signed_keys_out, - NULL); + (GNUNET_NO, + GNUNET_OS_INHERIT_STD_ALL, + NULL, NULL, NULL, + "taler-auditor-sign", + "taler-auditor-sign", + "-c", ass->config_filename, + "-u", "http://auditor/", + "-m", exchange_master_pub, + "-r", "auditor.in", + "-o", ass->signed_keys_out, + NULL); GNUNET_free (exchange_master_pub); if (NULL == ass->auditor_sign_proc) { @@ -161,7 +161,7 @@ auditor_sign_cleanup (void *cls, if (NULL != ass->auditor_sign_proc) { GNUNET_break (0 == GNUNET_OS_process_kill - (ass->auditor_sign_proc, SIGKILL)); + (ass->auditor_sign_proc, SIGKILL)); GNUNET_OS_process_wait (ass->auditor_sign_proc); GNUNET_OS_process_destroy (ass->auditor_sign_proc); ass->auditor_sign_proc = NULL; diff --git a/src/lib/testing_api_cmd_exec_keyup.c b/src/lib/testing_api_cmd_exec_keyup.c index e457a28e6..65f23693e 100644 --- a/src/lib/testing_api_cmd_exec_keyup.c +++ b/src/lib/testing_api_cmd_exec_keyup.c @@ -77,28 +77,28 @@ keyup_run (void *cls, if (GNUNET_YES == ks->with_now) { - ks->keyup_proc = GNUNET_OS_start_process - (GNUNET_NO, - GNUNET_OS_INHERIT_STD_ALL, - NULL, NULL, NULL, - "taler-exchange-keyup", - "taler-exchange-keyup", - "-c", ks->config_filename, - "-o", "auditor.in", - "--time", - GNUNET_STRINGS_absolute_time_to_string (ks->now), - NULL); + ks->keyup_proc = GNUNET_OS_start_process + (GNUNET_NO, + GNUNET_OS_INHERIT_STD_ALL, + NULL, NULL, NULL, + "taler-exchange-keyup", + "taler-exchange-keyup", + "-c", ks->config_filename, + "-o", "auditor.in", + "--time", + GNUNET_STRINGS_absolute_time_to_string (ks->now), + NULL); } else ks->keyup_proc = GNUNET_OS_start_process - (GNUNET_NO, - GNUNET_OS_INHERIT_STD_ALL, - NULL, NULL, NULL, - "taler-exchange-keyup", - "taler-exchange-keyup", - "-c", ks->config_filename, - "-o", "auditor.in", - NULL); + (GNUNET_NO, + GNUNET_OS_INHERIT_STD_ALL, + NULL, NULL, NULL, + "taler-exchange-keyup", + "taler-exchange-keyup", + "-c", ks->config_filename, + "-o", "auditor.in", + NULL); if (NULL == ks->keyup_proc) { @@ -180,8 +180,8 @@ keyup_traits (void *cls, struct TALER_TESTING_Command TALER_TESTING_cmd_exec_keyup_with_now (const char *label, - const char *config_filename, - struct GNUNET_TIME_Absolute now) + const char *config_filename, + struct GNUNET_TIME_Absolute now) { struct KeyupState *ks; diff --git a/src/lib/testing_api_cmd_exec_wirewatch.c b/src/lib/testing_api_cmd_exec_wirewatch.c index a81bf5c2b..c9ca42549 100644 --- a/src/lib/testing_api_cmd_exec_wirewatch.c +++ b/src/lib/testing_api_cmd_exec_wirewatch.c @@ -58,8 +58,8 @@ struct WirewatchState */ static void wirewatch_run (void *cls, - const struct TALER_TESTING_Command *cmd, - struct TALER_TESTING_Interpreter *is) + const struct TALER_TESTING_Command *cmd, + struct TALER_TESTING_Interpreter *is) { struct WirewatchState *ws = cls; diff --git a/src/lib/testing_api_cmd_fakebank_transfer.c b/src/lib/testing_api_cmd_fakebank_transfer.c index 570dee37a..729536b56 100644 --- a/src/lib/testing_api_cmd_fakebank_transfer.c +++ b/src/lib/testing_api_cmd_fakebank_transfer.c @@ -209,23 +209,23 @@ add_incoming_cb (void *cls, { if ( (0 == http_status) || (TALER_EC_DB_COMMIT_FAILED_ON_RETRY == ec) || - (MHD_HTTP_INTERNAL_SERVER_ERROR == http_status) ) + (MHD_HTTP_INTERNAL_SERVER_ERROR == http_status) ) { GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "Retrying fakebank transfer failed with %u/%d\n", - http_status, - (int) ec); - /* on DB conflicts, do not use backoff */ - if (TALER_EC_DB_COMMIT_FAILED_ON_RETRY == ec) - fts->backoff = GNUNET_TIME_UNIT_ZERO; - else - fts->backoff = EXCHANGE_LIB_BACKOFF (fts->backoff); - fts->retry_task = GNUNET_SCHEDULER_add_delayed - (fts->backoff, - &do_retry, - fts); - return; + "Retrying fakebank transfer failed with %u/%d\n", + http_status, + (int) ec); + /* on DB conflicts, do not use backoff */ + if (TALER_EC_DB_COMMIT_FAILED_ON_RETRY == ec) + fts->backoff = GNUNET_TIME_UNIT_ZERO; + else + fts->backoff = EXCHANGE_LIB_BACKOFF (fts->backoff); + fts->retry_task = GNUNET_SCHEDULER_add_delayed + (fts->backoff, + &do_retry, + fts); + return; } } GNUNET_break (0); @@ -273,7 +273,7 @@ fakebank_transfer_run (void *cls, const struct TALER_ReservePrivateKeyP *reserve_priv; ref = TALER_TESTING_interpreter_lookup_command - (is, fts->reserve_reference); + (is, fts->reserve_reference); if (NULL == ref) { GNUNET_break (0); @@ -317,9 +317,9 @@ fakebank_transfer_run (void *cls, if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg, - section, - "TIP_RESERVE_PRIV_FILENAME", - &keys)) + section, + "TIP_RESERVE_PRIV_FILENAME", + &keys)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Configuration fails to specify reserve" @@ -335,9 +335,9 @@ fakebank_transfer_run (void *cls, { GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR, - section, - "TIP_RESERVE_PRIV_FILENAME", - "Failed to read private key"); + section, + "TIP_RESERVE_PRIV_FILENAME", + "Failed to read private key"); GNUNET_free (section); TALER_TESTING_interpreter_fail (is); return; @@ -349,19 +349,19 @@ fakebank_transfer_run (void *cls, } else { - /* No referenced reserve, no instance to take priv - * from, no explicit subject given: create new key! */ - struct GNUNET_CRYPTO_EddsaPrivateKey *priv; + /* No referenced reserve, no instance to take priv + * from, no explicit subject given: create new key! */ + struct GNUNET_CRYPTO_EddsaPrivateKey *priv; - priv = GNUNET_CRYPTO_eddsa_key_create (); - fts->reserve_priv.eddsa_priv = *priv; - GNUNET_free (priv); + priv = GNUNET_CRYPTO_eddsa_key_create (); + fts->reserve_priv.eddsa_priv = *priv; + GNUNET_free (priv); } } GNUNET_CRYPTO_eddsa_key_get_public (&fts->reserve_priv.eddsa_priv, &reserve_pub.eddsa_pub); subject = GNUNET_STRINGS_data_to_string_alloc - (&reserve_pub, sizeof (reserve_pub)); + (&reserve_pub, sizeof (reserve_pub)); } auth.method = TALER_BANK_AUTH_BASIC; @@ -369,16 +369,16 @@ fakebank_transfer_run (void *cls, auth.details.basic.password = (char *) fts->auth_password; fts->is = is; fts->aih = TALER_BANK_admin_add_incoming - (TALER_TESTING_interpreter_get_context (is), - fts->bank_url, - &auth, - fts->exchange_url, - subject, - &fts->amount, - fts->debit_account_no, - fts->credit_account_no, - &add_incoming_cb, - fts); + (TALER_TESTING_interpreter_get_context (is), + fts->bank_url, + &auth, + fts->exchange_url, + subject, + &fts->amount, + fts->debit_account_no, + fts->credit_account_no, + &add_incoming_cb, + fts); GNUNET_free (subject); if (NULL == fts->aih) { @@ -456,9 +456,9 @@ fakebank_transfer_traits (void *cls, /* A reserve priv must exist if no subject was given. */ else traits[MANDATORY - 1] = TALER_TESTING_make_trait_reserve_priv - (0, &fts->reserve_priv), + (0, &fts->reserve_priv), - traits[MANDATORY] = TALER_TESTING_trait_end (); + traits[MANDATORY] = TALER_TESTING_trait_end (); return TALER_TESTING_get_trait (traits, ret, @@ -491,13 +491,13 @@ fakebank_transfer_traits (void *cls, struct TALER_TESTING_Command TALER_TESTING_cmd_fakebank_transfer (const char *label, - const char *amount, - const char *bank_url, - uint64_t debit_account_no, - uint64_t credit_account_no, - const char *auth_username, - const char *auth_password, - const char *exchange_url) + const char *amount, + const char *bank_url, + uint64_t debit_account_no, + uint64_t credit_account_no, + const char *auth_username, + const char *auth_password, + const char *exchange_url) { struct FakebankTransferState *fts; @@ -556,14 +556,14 @@ TALER_TESTING_cmd_fakebank_transfer struct TALER_TESTING_Command TALER_TESTING_cmd_fakebank_transfer_with_subject (const char *label, - const char *amount, - const char *bank_url, - uint64_t debit_account_no, - uint64_t credit_account_no, - const char *auth_username, - const char *auth_password, - const char *subject, - const char *exchange_url) + const char *amount, + const char *bank_url, + uint64_t debit_account_no, + uint64_t credit_account_no, + const char *auth_username, + const char *auth_password, + const char *subject, + const char *exchange_url) { struct FakebankTransferState *fts; @@ -629,14 +629,14 @@ TALER_TESTING_cmd_fakebank_transfer_with_subject struct TALER_TESTING_Command TALER_TESTING_cmd_fakebank_transfer_with_ref (const char *label, - const char *amount, - const char *bank_url, - uint64_t debit_account_no, - uint64_t credit_account_no, - const char *auth_username, - const char *auth_password, - const char *ref, - const char *exchange_url) + const char *amount, + const char *bank_url, + uint64_t debit_account_no, + uint64_t credit_account_no, + const char *auth_username, + const char *auth_password, + const char *ref, + const char *exchange_url) { struct FakebankTransferState *fts; @@ -703,15 +703,15 @@ TALER_TESTING_cmd_fakebank_transfer_with_ref struct TALER_TESTING_Command TALER_TESTING_cmd_fakebank_transfer_with_instance (const char *label, - const char *amount, - const char *bank_url, - uint64_t debit_account_no, - uint64_t credit_account_no, - const char *auth_username, - const char *auth_password, - const char *instance, - const char *exchange_url, - const char *config_filename) + const char *amount, + const char *bank_url, + uint64_t debit_account_no, + uint64_t credit_account_no, + const char *auth_username, + const char *auth_password, + const char *instance, + const char *exchange_url, + const char *config_filename) { struct FakebankTransferState *fts; diff --git a/src/lib/testing_api_cmd_payback.c b/src/lib/testing_api_cmd_payback.c index de394fe26..c69d1d089 100644 --- a/src/lib/testing_api_cmd_payback.c +++ b/src/lib/testing_api_cmd_payback.c @@ -209,7 +209,7 @@ payback_cb (void *cls, } reserve_cmd = TALER_TESTING_interpreter_lookup_command - (is, cref); + (is, cref); GNUNET_free (cref); if (NULL == reserve_cmd) @@ -289,7 +289,7 @@ payback_cb (void *cls, return; } if (GNUNET_OK != TALER_TESTING_get_trait_reserve_priv - (reserve_cmd, idx, &reserve_priv)) + (reserve_cmd, idx, &reserve_priv)) { GNUNET_break (0); TALER_TESTING_interpreter_fail (is); @@ -348,7 +348,7 @@ payback_run (void *cls, } coin_cmd = TALER_TESTING_interpreter_lookup_command - (is, cref); + (is, cref); GNUNET_free (cref); if (NULL == coin_cmd) @@ -359,7 +359,7 @@ payback_run (void *cls, } if (GNUNET_OK != TALER_TESTING_get_trait_coin_priv - (coin_cmd, idx, &coin_priv)) + (coin_cmd, idx, &coin_priv)) { GNUNET_break (0); TALER_TESTING_interpreter_fail (is); @@ -367,7 +367,7 @@ payback_run (void *cls, } if (GNUNET_OK != TALER_TESTING_get_trait_blinding_key - (coin_cmd, idx, &blinding_key)) + (coin_cmd, idx, &blinding_key)) { GNUNET_break (0); TALER_TESTING_interpreter_fail (is); @@ -377,7 +377,7 @@ payback_run (void *cls, planchet.blinding_key = *blinding_key; if (GNUNET_OK != TALER_TESTING_get_trait_denom_pub - (coin_cmd, idx, &denom_pub)) + (coin_cmd, idx, &denom_pub)) { GNUNET_break (0); TALER_TESTING_interpreter_fail (is); @@ -385,7 +385,7 @@ payback_run (void *cls, } if (GNUNET_OK != TALER_TESTING_get_trait_denom_sig - (coin_cmd, idx, &coin_sig)) + (coin_cmd, idx, &coin_sig)) { GNUNET_break (0); TALER_TESTING_interpreter_fail (is); @@ -423,7 +423,7 @@ revoke_cleanup (void *cls, if (NULL != rs->revoke_proc) { GNUNET_break (0 == GNUNET_OS_process_kill - (rs->revoke_proc, SIGKILL)); + (rs->revoke_proc, SIGKILL)); GNUNET_OS_process_wait (rs->revoke_proc); GNUNET_OS_process_destroy (rs->revoke_proc); rs->revoke_proc = NULL; @@ -506,7 +506,7 @@ revoke_run (void *cls, rs->is = is; /* Get denom pub from trait */ coin_cmd = TALER_TESTING_interpreter_lookup_command - (is, rs->coin_reference); + (is, rs->coin_reference); if (NULL == coin_cmd) { @@ -516,24 +516,24 @@ revoke_run (void *cls, } GNUNET_assert (GNUNET_OK == TALER_TESTING_get_trait_denom_pub - (coin_cmd, 0, &denom_pub)); + (coin_cmd, 0, &denom_pub)); GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Trying to revoke denom '%s..'\n", TALER_B2S (&denom_pub->h_key)); rs->dhks = GNUNET_STRINGS_data_to_string_alloc - (&denom_pub->h_key, sizeof (struct GNUNET_HashCode)); + (&denom_pub->h_key, sizeof (struct GNUNET_HashCode)); rs->revoke_proc = GNUNET_OS_start_process - (GNUNET_NO, - GNUNET_OS_INHERIT_STD_ALL, - NULL, NULL, NULL, - "taler-exchange-keyup", - "taler-exchange-keyup", - "-c", rs->config_filename, - "-r", rs->dhks, - NULL); + (GNUNET_NO, + GNUNET_OS_INHERIT_STD_ALL, + NULL, NULL, NULL, + "taler-exchange-keyup", + "taler-exchange-keyup", + "-c", rs->config_filename, + "-r", rs->dhks, + NULL); if (NULL == rs->revoke_proc) { diff --git a/src/lib/testing_api_cmd_refresh.c b/src/lib/testing_api_cmd_refresh.c index b2754edd8..5d1472a01 100644 --- a/src/lib/testing_api_cmd_refresh.c +++ b/src/lib/testing_api_cmd_refresh.c @@ -304,7 +304,7 @@ reveal_cb (void *cls, { if ( (0 == http_status) || (TALER_EC_DB_COMMIT_FAILED_ON_RETRY == ec) || - (MHD_HTTP_INTERNAL_SERVER_ERROR == http_status) ) + (MHD_HTTP_INTERNAL_SERVER_ERROR == http_status) ) { GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Retrying refresh reveal failed with %u/%d\n", @@ -333,7 +333,7 @@ reveal_cb (void *cls, return; } melt_cmd = TALER_TESTING_interpreter_lookup_command - (rrs->is, rrs->melt_reference); + (rrs->is, rrs->melt_reference); if (NULL == melt_cmd) { GNUNET_break (0); @@ -345,8 +345,8 @@ reveal_cb (void *cls, { case MHD_HTTP_OK: rrs->fresh_coins = GNUNET_new_array - (num_coins, struct TALER_TESTING_FreshCoinData); - for (unsigned int i=0; ifresh_coins[i]; @@ -362,7 +362,7 @@ reveal_cb (void *cls, fc->coin_priv = coin_privs[i].coin_priv; fc->blinding_key = coin_privs[i].blinding_key; fc->sig.rsa_signature = GNUNET_CRYPTO_rsa_signature_dup - (sigs[i].rsa_signature); + (sigs[i].rsa_signature); } break; default: @@ -392,7 +392,7 @@ refresh_reveal_run (void *cls, rrs->is = is; melt_cmd = TALER_TESTING_interpreter_lookup_command - (is, rrs->melt_reference); + (is, rrs->melt_reference); if (NULL == melt_cmd) { @@ -402,11 +402,11 @@ refresh_reveal_run (void *cls, } rms = melt_cmd->cls; rrs->rrh = TALER_EXCHANGE_refresh_reveal - (is->exchange, - rms->refresh_data_length, - rms->refresh_data, - rms->noreveal_index, - &reveal_cb, rrs); + (is->exchange, + rms->refresh_data_length, + rms->refresh_data, + rms->noreveal_index, + &reveal_cb, rrs); if (NULL == rrs->rrh) { @@ -446,7 +446,7 @@ refresh_reveal_cleanup (void *cls, rrs->retry_task = NULL; } - for (unsigned int j=0; j < rrs->num_fresh_coins; j++) + for (unsigned int j = 0; j < rrs->num_fresh_coins; j++) GNUNET_CRYPTO_rsa_signature_free (rrs->fresh_coins[j].sig.rsa_signature); GNUNET_free_non_null (rrs->fresh_coins); @@ -530,18 +530,18 @@ link_cb (void *cls, { if ( (0 == http_status) || (TALER_EC_DB_COMMIT_FAILED_ON_RETRY == ec) || - (MHD_HTTP_INTERNAL_SERVER_ERROR == http_status) ) + (MHD_HTTP_INTERNAL_SERVER_ERROR == http_status) ) { GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Retrying refresh link failed with %u/%d\n", http_status, (int) ec); - /* on DB conflicts, do not use backoff */ - if (TALER_EC_DB_COMMIT_FAILED_ON_RETRY == ec) - rls->backoff = GNUNET_TIME_UNIT_ZERO; - else - rls->backoff = EXCHANGE_LIB_BACKOFF (rls->backoff); - rls->retry_task = GNUNET_SCHEDULER_add_delayed (rls->backoff, + /* on DB conflicts, do not use backoff */ + if (TALER_EC_DB_COMMIT_FAILED_ON_RETRY == ec) + rls->backoff = GNUNET_TIME_UNIT_ZERO; + else + rls->backoff = EXCHANGE_LIB_BACKOFF (rls->backoff); + rls->retry_task = GNUNET_SCHEDULER_add_delayed (rls->backoff, &do_link_retry, rls); return; @@ -559,7 +559,7 @@ link_cb (void *cls, return; } reveal_cmd = TALER_TESTING_interpreter_lookup_command - (rls->is, rls->reveal_reference); + (rls->is, rls->reveal_reference); if (NULL == reveal_cmd) { @@ -573,7 +573,7 @@ link_cb (void *cls, case MHD_HTTP_OK: /* check that number of coins returned matches */ if (GNUNET_OK != TALER_TESTING_get_trait_uint - (reveal_cmd, 0, &num_fresh_coins)) + (reveal_cmd, 0, &num_fresh_coins)) { GNUNET_break (0); TALER_TESTING_interpreter_fail (rls->is); @@ -586,15 +586,15 @@ link_cb (void *cls, num_coins, *num_fresh_coins, __FILE__, - __LINE__); + __LINE__); TALER_TESTING_interpreter_fail (rls->is); return; } /* check that the coins match */ - for (unsigned int i=0;iis); return; } - for (unsigned int i=0;ikey.rsa_public_key, - pubs[j].rsa_public_key)) ) + (fc[i].pk->key.rsa_public_key, + pubs[j].rsa_public_key)) ) { found++; break; @@ -630,7 +630,7 @@ link_cb (void *cls, { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Only %u/%u coins match expectations\n", - found, num_coins); + found, num_coins); GNUNET_break (0); TALER_TESTING_interpreter_fail (rls->is); return; @@ -666,7 +666,7 @@ refresh_link_run (void *cls, rls->is = is; reveal_cmd = TALER_TESTING_interpreter_lookup_command - (rls->is, rls->reveal_reference); + (rls->is, rls->reveal_reference); if (NULL == reveal_cmd) { @@ -676,7 +676,7 @@ refresh_link_run (void *cls, } rrs = reveal_cmd->cls; melt_cmd = TALER_TESTING_interpreter_lookup_command - (rls->is, rrs->melt_reference); + (rls->is, rrs->melt_reference); if (NULL == melt_cmd) { @@ -689,7 +689,7 @@ refresh_link_run (void *cls, { rms = melt_cmd->cls; coin_cmd = TALER_TESTING_interpreter_lookup_command - (rls->is, rms->coin_reference); + (rls->is, rms->coin_reference); if (NULL == coin_cmd) { GNUNET_break (0); @@ -700,7 +700,7 @@ refresh_link_run (void *cls, const struct TALER_CoinSpendPrivateKeyP *coin_priv; if (GNUNET_OK != TALER_TESTING_get_trait_coin_priv - (coin_cmd, 0, &coin_priv)) + (coin_cmd, 0, &coin_priv)) { GNUNET_break (0); TALER_TESTING_interpreter_fail (rls->is); @@ -709,7 +709,7 @@ refresh_link_run (void *cls, /* finally, use private key from withdraw sign command */ rls->rlh = TALER_EXCHANGE_refresh_link - (is->exchange, coin_priv, &link_cb, rls); + (is->exchange, coin_priv, &link_cb, rls); if (NULL == rls->rlh) { @@ -812,32 +812,32 @@ melt_cb (void *cls, { if ( (0 == http_status) || (TALER_EC_DB_COMMIT_FAILED_ON_RETRY == ec) || - (MHD_HTTP_INTERNAL_SERVER_ERROR == http_status) ) + (MHD_HTTP_INTERNAL_SERVER_ERROR == http_status) ) { GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Retrying refresh melt failed with %u/%d\n", http_status, (int) ec); - /* on DB conflicts, do not use backoff */ - if (TALER_EC_DB_COMMIT_FAILED_ON_RETRY == ec) - rms->backoff = GNUNET_TIME_UNIT_ZERO; - else - rms->backoff = EXCHANGE_LIB_BACKOFF (rms->backoff); - rms->retry_task = GNUNET_SCHEDULER_add_delayed - (rms->backoff, - &do_melt_retry, - rms); + /* on DB conflicts, do not use backoff */ + if (TALER_EC_DB_COMMIT_FAILED_ON_RETRY == ec) + rms->backoff = GNUNET_TIME_UNIT_ZERO; + else + rms->backoff = EXCHANGE_LIB_BACKOFF (rms->backoff); + rms->retry_task = GNUNET_SCHEDULER_add_delayed + (rms->backoff, + &do_melt_retry, + rms); return; } } GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Unexpected response code %u/%d to command %s in %s:%u\n", - http_status, - (int) ec, - rms->is->commands[rms->is->ip].label, - __FILE__, - __LINE__); + "Unexpected response code %u/%d to command %s in %s:%u\n", + http_status, + (int) ec, + rms->is->commands[rms->is->ip].label, + __FILE__, + __LINE__); json_dumpf (full_response, stderr, 0); TALER_TESTING_interpreter_fail (rms->is); return; @@ -849,8 +849,8 @@ melt_cb (void *cls, TALER_LOG_DEBUG ("Doubling the melt (%s)\n", rms->is->commands[rms->is->ip].label); rms->rmh = TALER_EXCHANGE_refresh_melt - (rms->is->exchange, rms->refresh_data_length, - rms->refresh_data, &melt_cb, rms); + (rms->is->exchange, rms->refresh_data_length, + rms->refresh_data, &melt_cb, rms); rms->double_melt = GNUNET_NO; return; } @@ -882,13 +882,13 @@ refresh_melt_run (void *cls, melt_fresh_amounts = default_melt_fresh_amounts; rms->is = is; rms->noreveal_index = UINT16_MAX; - for (num_fresh_coins=0; + for (num_fresh_coins = 0; NULL != melt_fresh_amounts[num_fresh_coins]; - num_fresh_coins++) ; + num_fresh_coins++); rms->num_fresh_coins = num_fresh_coins; rms->fresh_pks = GNUNET_new_array - (num_fresh_coins, - struct TALER_EXCHANGE_DenomPublicKey); + (num_fresh_coins, + struct TALER_EXCHANGE_DenomPublicKey); { struct TALER_Amount melt_amount; struct TALER_Amount fresh_amount; @@ -897,8 +897,8 @@ refresh_melt_run (void *cls, const struct TALER_TESTING_Command *coin_command; if (NULL == (coin_command - = TALER_TESTING_interpreter_lookup_command - (is, rms->coin_reference))) + = TALER_TESTING_interpreter_lookup_command + (is, rms->coin_reference))) { GNUNET_break (0); TALER_TESTING_interpreter_fail (rms->is); @@ -906,7 +906,7 @@ refresh_melt_run (void *cls, } if (GNUNET_OK != TALER_TESTING_get_trait_coin_priv - (coin_command, 0, &rms->melt_priv)) + (coin_command, 0, &rms->melt_priv)) { GNUNET_break (0); TALER_TESTING_interpreter_fail (rms->is); @@ -923,7 +923,7 @@ refresh_melt_run (void *cls, return; } if (GNUNET_OK != TALER_TESTING_get_trait_denom_pub - (coin_command, 0, &melt_denom_pub)) + (coin_command, 0, &melt_denom_pub)) { GNUNET_break (0); TALER_TESTING_interpreter_fail (rms->is); @@ -932,12 +932,12 @@ refresh_melt_run (void *cls, /* Melt amount starts with the melt fee of the old coin; we'll add the values and withdraw fees of the fresh coins next */ melt_amount = melt_denom_pub->fee_refresh; - for (unsigned int i=0;iexchange), &fresh_amount); + (TALER_EXCHANGE_get_keys (is->exchange), &fresh_amount); if (NULL == fresh_pk) { GNUNET_break (0); @@ -966,9 +966,10 @@ refresh_melt_run (void *cls, rms->fresh_pks[i] = *fresh_pk; } rms->refresh_data = TALER_EXCHANGE_refresh_prepare - (rms->melt_priv, &melt_amount, melt_sig, melt_denom_pub, - GNUNET_YES, num_fresh_coins, rms->fresh_pks, - &rms->refresh_data_length); + (rms->melt_priv, &melt_amount, melt_sig, + melt_denom_pub, + GNUNET_YES, num_fresh_coins, rms->fresh_pks, + &rms->refresh_data_length); if (NULL == rms->refresh_data) { @@ -977,8 +978,8 @@ refresh_melt_run (void *cls, return; } rms->rmh = TALER_EXCHANGE_refresh_melt - (is->exchange, rms->refresh_data_length, - rms->refresh_data, &melt_cb, rms); + (is->exchange, rms->refresh_data_length, + rms->refresh_data, &melt_cb, rms); if (NULL == rms->rmh) { @@ -1126,9 +1127,9 @@ parse_amounts (struct RefreshMeltState *rms, struct TALER_TESTING_Command TALER_TESTING_cmd_refresh_melt (const char *label, - const char *coin_reference, - unsigned int expected_response_code, - ...) + const char *coin_reference, + unsigned int expected_response_code, + ...) { struct RefreshMeltState *rms; va_list ap; @@ -1170,9 +1171,9 @@ TALER_TESTING_cmd_refresh_melt struct TALER_TESTING_Command TALER_TESTING_cmd_refresh_melt_double (const char *label, - const char *coin_reference, - unsigned int expected_response_code, - ...) + const char *coin_reference, + unsigned int expected_response_code, + ...) { struct RefreshMeltState *rms; va_list ap; @@ -1239,30 +1240,30 @@ refresh_reveal_traits (void *cls, struct TALER_TESTING_Trait traits[NUM_TRAITS]; /* Making coin privs traits */ - for (unsigned int i=0; ifresh_coins[i].coin_priv); + (i, &rrs->fresh_coins[i].coin_priv); /* Making denom pubs traits */ - for (unsigned int i=0; ifresh_coins[i].pk); + (i, rrs->fresh_coins[i].pk); /* Making denom sigs traits */ - for (unsigned int i=0; ifresh_coins[i].sig); + (i, &rrs->fresh_coins[i].sig); /* blinding key traits */ - for (unsigned int i=0; ifresh_coins[i].blinding_key), - /* number of fresh coins */ - traits[(num_coins * 4)] = TALER_TESTING_make_trait_uint - (0, &rrs->num_fresh_coins); + /* number of fresh coins */ + traits[(num_coins * 4)] = TALER_TESTING_make_trait_uint + (0, &rrs->num_fresh_coins); /* whole array of fresh coins */ traits[(num_coins * 4) + 1] @@ -1291,8 +1292,8 @@ refresh_reveal_traits (void *cls, struct TALER_TESTING_Command TALER_TESTING_cmd_refresh_reveal (const char *label, - const char *melt_reference, - unsigned int expected_response_code) + const char *melt_reference, + unsigned int expected_response_code) { struct RefreshRevealState *rrs; @@ -1343,8 +1344,8 @@ TALER_TESTING_cmd_refresh_reveal_with_retry (struct TALER_TESTING_Command cmd) struct TALER_TESTING_Command TALER_TESTING_cmd_refresh_link (const char *label, - const char *reveal_reference, - unsigned int expected_response_code) + const char *reveal_reference, + unsigned int expected_response_code) { struct RefreshLinkState *rrs; diff --git a/src/lib/testing_api_cmd_refund.c b/src/lib/testing_api_cmd_refund.c index 55f329dd0..91085f364 100644 --- a/src/lib/testing_api_cmd_refund.c +++ b/src/lib/testing_api_cmd_refund.c @@ -92,7 +92,7 @@ struct RefundState static void refund_cb (void *cls, unsigned int http_status, - enum TALER_ErrorCode ec, + enum TALER_ErrorCode ec, const struct TALER_ExchangePublicKeyP *exchange_pub, const json_t *obj) { @@ -169,7 +169,7 @@ refund_run (void *cls, } coin_cmd = TALER_TESTING_interpreter_lookup_command - (is, rs->coin_reference); + (is, rs->coin_reference); if (NULL == coin_cmd) { @@ -179,7 +179,7 @@ refund_run (void *cls, } if (GNUNET_OK != TALER_TESTING_get_trait_contract_terms - (coin_cmd, 0, &contract_terms)) + (coin_cmd, 0, &contract_terms)) { GNUNET_break (0); TALER_TESTING_interpreter_fail (is); @@ -192,7 +192,7 @@ refund_run (void *cls, /* Hunting for a coin .. */ if (GNUNET_OK != TALER_TESTING_get_trait_coin_priv - (coin_cmd, 0, &coin_priv)) + (coin_cmd, 0, &coin_priv)) { GNUNET_break (0); TALER_TESTING_interpreter_fail (is); @@ -202,7 +202,7 @@ refund_run (void *cls, GNUNET_CRYPTO_eddsa_key_get_public (&coin_priv->eddsa_priv, &coin.eddsa_pub); if (GNUNET_OK != TALER_TESTING_get_trait_peer_key - (coin_cmd, 0, &merchant_priv)) + (coin_cmd, 0, &merchant_priv)) { GNUNET_break (0); TALER_TESTING_interpreter_fail (is); @@ -210,14 +210,14 @@ refund_run (void *cls, } rs->rh = TALER_EXCHANGE_refund - (rs->exchange, - &refund_amount, - &refund_fee, - &h_contract_terms, - &coin, - rs->refund_transaction_id, - (const struct TALER_MerchantPrivateKeyP *) merchant_priv, - &refund_cb, rs); + (rs->exchange, + &refund_amount, + &refund_fee, + &h_contract_terms, + &coin, + rs->refund_transaction_id, + (const struct TALER_MerchantPrivateKeyP *) merchant_priv, + &refund_cb, rs); GNUNET_assert (NULL != rs->rh); } @@ -307,11 +307,11 @@ TALER_TESTING_cmd_refund (const char *label, struct TALER_TESTING_Command TALER_TESTING_cmd_refund_with_id (const char *label, - unsigned int expected_response_code, - const char *refund_amount, - const char *refund_fee, - const char *coin_reference, - uint64_t refund_transaction_id) + unsigned int expected_response_code, + const char *refund_amount, + const char *refund_fee, + const char *coin_reference, + uint64_t refund_transaction_id) { struct RefundState *rs; diff --git a/src/lib/testing_api_cmd_serialize_keys.c b/src/lib/testing_api_cmd_serialize_keys.c index bacd041a7..7ef03fe5d 100644 --- a/src/lib/testing_api_cmd_serialize_keys.c +++ b/src/lib/testing_api_cmd_serialize_keys.c @@ -96,7 +96,7 @@ serialize_keys_run (void *cls, TALER_TESTING_interpreter_fail (is); sks->exchange_url = GNUNET_strdup - (TALER_EXCHANGE_get_base_url (is->exchange)); + (TALER_EXCHANGE_get_base_url (is->exchange)); TALER_EXCHANGE_disconnect (is->exchange); is->exchange = NULL; is->working = GNUNET_NO; @@ -182,7 +182,7 @@ connect_with_state_run (void *cls, cwss->is = is; state_cmd = TALER_TESTING_interpreter_lookup_command - (is, cwss->state_reference); + (is, cwss->state_reference); /* Command providing serialized keys not found. */ if (NULL == state_cmd) @@ -195,27 +195,27 @@ connect_with_state_run (void *cls, GNUNET_assert (GNUNET_OK == TALER_TESTING_get_trait_exchange_keys (state_cmd, - 0, - &serialized_keys)); + 0, + &serialized_keys)); TALER_LOG_DEBUG ("Serialized key-state: %s\n", json_dumps (serialized_keys, JSON_INDENT (1))); GNUNET_assert - (GNUNET_OK == TALER_TESTING_get_trait_url - (state_cmd, - 0, - &exchange_url)); + (GNUNET_OK == TALER_TESTING_get_trait_url + (state_cmd, + 0, + &exchange_url)); is->exchange = TALER_EXCHANGE_connect - (is->ctx, - exchange_url, - TALER_TESTING_cert_cb, - cwss, - TALER_EXCHANGE_OPTION_DATA, - serialized_keys, - TALER_EXCHANGE_OPTION_END); + (is->ctx, + exchange_url, + TALER_TESTING_cert_cb, + cwss, + TALER_EXCHANGE_OPTION_DATA, + serialized_keys, + TALER_EXCHANGE_OPTION_END); cwss->consumed = GNUNET_YES; } @@ -231,7 +231,7 @@ connect_with_state_run (void *cls, static void connect_with_state_cleanup (void *cls, - const struct TALER_TESTING_Command *cmd) + const struct TALER_TESTING_Command *cmd) { struct ConnectWithStateState *cwss = cls; diff --git a/src/lib/testing_api_cmd_signal.c b/src/lib/testing_api_cmd_signal.c index f4fd8bb76..5a6332947 100644 --- a/src/lib/testing_api_cmd_signal.c +++ b/src/lib/testing_api_cmd_signal.c @@ -59,7 +59,7 @@ signal_run (void *cls, struct SignalState *ss = cls; GNUNET_break (0 == GNUNET_OS_process_kill - (ss->process, ss->signal)); + (ss->process, ss->signal)); GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Signaling '%d'..\n", ss->signal); diff --git a/src/lib/testing_api_cmd_sleep.c b/src/lib/testing_api_cmd_sleep.c index 188671bee..326f38b53 100644 --- a/src/lib/testing_api_cmd_sleep.c +++ b/src/lib/testing_api_cmd_sleep.c @@ -183,13 +183,13 @@ wait_service_run (void *cls, if (10 == iter++) { TALER_LOG_ERROR ("Could not reach the proxied service\n"); - TALER_TESTING_interpreter_fail (is); + TALER_TESTING_interpreter_fail (is); GNUNET_free (wget_cmd); - return; + return; } } while (0 != system (wget_cmd)); - + GNUNET_free (wget_cmd); TALER_TESTING_interpreter_next (is); } @@ -214,7 +214,7 @@ TALER_TESTING_cmd_wait_service (const char *label, .traits = wait_service_traits, .cls = (void *) url }; - + return cmd; } diff --git a/src/lib/testing_api_cmd_status.c b/src/lib/testing_api_cmd_status.c index 40c8c550b..0dcea1233 100644 --- a/src/lib/testing_api_cmd_status.c +++ b/src/lib/testing_api_cmd_status.c @@ -76,12 +76,12 @@ struct StatusState static void reserve_status_cb (void *cls, - unsigned int http_status, - enum TALER_ErrorCode ec, - const json_t *json, - const struct TALER_Amount *balance, - unsigned int history_length, - const struct TALER_EXCHANGE_ReserveHistory *history) + unsigned int http_status, + enum TALER_ErrorCode ec, + const json_t *json, + const struct TALER_Amount *balance, + unsigned int history_length, + const struct TALER_EXCHANGE_ReserveHistory *history) { struct StatusState *ss = cls; struct TALER_Amount eb; @@ -99,7 +99,7 @@ reserve_status_cb } GNUNET_assert (GNUNET_OK == TALER_string_to_amount - (ss->expected_balance, &eb)); + (ss->expected_balance, &eb)); if (0 != TALER_amount_cmp (&eb, balance)) { @@ -154,7 +154,7 @@ status_run (void *cls, create_reserve = TALER_TESTING_interpreter_lookup_command - (is, ss->reserve_reference); + (is, ss->reserve_reference); if (NULL == create_reserve) { @@ -166,9 +166,9 @@ status_run (void *cls, /* NOTE: the following line might generate a ERROR log * statements, but it can be ignored. */ if (GNUNET_OK == TALER_TESTING_get_trait_reserve_priv - (create_reserve, - 0, - &reserve_priv)) + (create_reserve, + 0, + &reserve_priv)) { GNUNET_CRYPTO_eddsa_key_get_public (&reserve_priv->eddsa_priv, &reserve_pub.eddsa_pub); @@ -178,9 +178,9 @@ status_run (void *cls, const char *transfer_subject; if (GNUNET_OK != TALER_TESTING_get_trait_transfer_subject - (create_reserve, - 0, - &transfer_subject)) + (create_reserve, + 0, + &transfer_subject)) { GNUNET_break (0); TALER_LOG_ERROR ("The reserve has neither a priv nor a subject line.\n"); diff --git a/src/lib/testing_api_cmd_track.c b/src/lib/testing_api_cmd_track.c index 1c2130839..e32d24ce2 100644 --- a/src/lib/testing_api_cmd_track.c +++ b/src/lib/testing_api_cmd_track.c @@ -158,13 +158,13 @@ struct TrackTransferState static void deposit_wtid_cb (void *cls, - unsigned int http_status, - enum TALER_ErrorCode ec, - const struct TALER_ExchangePublicKeyP *exchange_pub, - const json_t *json, - const struct TALER_WireTransferIdentifierRawP *wtid, - struct GNUNET_TIME_Absolute execution_time, - const struct TALER_Amount *coin_contribution) + unsigned int http_status, + enum TALER_ErrorCode ec, + const struct TALER_ExchangePublicKeyP *exchange_pub, + const json_t *json, + const struct TALER_WireTransferIdentifierRawP *wtid, + struct GNUNET_TIME_Absolute execution_time, + const struct TALER_Amount *coin_contribution) { struct TrackTransactionState *tts = cls; struct TALER_TESTING_Interpreter *is = tts->is; @@ -197,7 +197,7 @@ deposit_wtid_cb sizeof (*wtid)); bank_transfer_cmd = TALER_TESTING_interpreter_lookup_command - (is, tts->bank_transfer_reference); + (is, tts->bank_transfer_reference); if (NULL == bank_transfer_cmd) { @@ -210,8 +210,8 @@ deposit_wtid_cb const char *transfer_subject; if (GNUNET_OK != - TALER_TESTING_get_trait_transfer_subject - (bank_transfer_cmd, 0, &transfer_subject)) + TALER_TESTING_get_trait_transfer_subject + (bank_transfer_cmd, 0, &transfer_subject)) { GNUNET_break (0); TALER_TESTING_interpreter_fail (is); @@ -268,7 +268,7 @@ track_transaction_run (void *cls, tts->is = is; transaction_cmd = TALER_TESTING_interpreter_lookup_command - (tts->is, tts->transaction_reference); + (tts->is, tts->transaction_reference); if (NULL == transaction_cmd) { @@ -278,7 +278,7 @@ track_transaction_run (void *cls, } if (GNUNET_OK != TALER_TESTING_get_trait_coin_priv - (transaction_cmd, tts->coin_index, &coin_priv)) + (transaction_cmd, tts->coin_index, &coin_priv)) { GNUNET_break (0); TALER_TESTING_interpreter_fail (tts->is); @@ -290,7 +290,7 @@ track_transaction_run (void *cls, /* Get the strings.. */ if (GNUNET_OK != TALER_TESTING_get_trait_wire_details - (transaction_cmd, 0, &wire_details)) + (transaction_cmd, 0, &wire_details)) { GNUNET_break (0); TALER_TESTING_interpreter_fail (tts->is); @@ -298,7 +298,7 @@ track_transaction_run (void *cls, } if (GNUNET_OK != TALER_TESTING_get_trait_contract_terms - (transaction_cmd, 0, &contract_terms)) + (transaction_cmd, 0, &contract_terms)) { GNUNET_break (0); TALER_TESTING_interpreter_fail (tts->is); @@ -317,12 +317,12 @@ track_transaction_run (void *cls, ( (GNUNET_OK == TALER_JSON_merchant_wire_signature_hash (wire_details, &h_wire_details)) && - (GNUNET_OK == - TALER_JSON_hash (contract_terms, - &h_contract_terms)) ); + (GNUNET_OK == + TALER_JSON_hash (contract_terms, + &h_contract_terms)) ); if (GNUNET_OK != TALER_TESTING_get_trait_peer_key - (transaction_cmd, 0, &merchant_priv)) + (transaction_cmd, 0, &merchant_priv)) { GNUNET_break (0); TALER_TESTING_interpreter_fail (tts->is); @@ -330,13 +330,13 @@ track_transaction_run (void *cls, } tts->tth = TALER_EXCHANGE_track_transaction - (is->exchange, - (struct TALER_MerchantPrivateKeyP *) merchant_priv, - &h_wire_details, - &h_contract_terms, - &coin_pub, - &deposit_wtid_cb, - tts); + (is->exchange, + (struct TALER_MerchantPrivateKeyP *) merchant_priv, + &h_wire_details, + &h_contract_terms, + &coin_pub, + &deposit_wtid_cb, + tts); GNUNET_assert (NULL != tts->tth); } @@ -352,7 +352,7 @@ track_transaction_run (void *cls, static void track_transaction_cleanup (void *cls, - const struct TALER_TESTING_Command *cmd) + const struct TALER_TESTING_Command *cmd) { struct TrackTransactionState *tts = cls; @@ -415,10 +415,10 @@ track_transaction_traits (void *cls, struct TALER_TESTING_Command TALER_TESTING_cmd_track_transaction (const char *label, - const char *transaction_reference, - unsigned int coin_index, - unsigned int expected_response_code, - const char *bank_transfer_reference) + const char *transaction_reference, + unsigned int coin_index, + unsigned int expected_response_code, + const char *bank_transfer_reference) { struct TrackTransactionState *tts; @@ -494,16 +494,16 @@ track_transfer_cleanup (void *cls, static void track_transfer_cb (void *cls, - unsigned int http_status, - enum TALER_ErrorCode ec, - const struct TALER_ExchangePublicKeyP *exchange_pub, - const json_t *json, - const struct GNUNET_HashCode *h_wire, - struct GNUNET_TIME_Absolute execution_time, - const struct TALER_Amount *total_amount, - const struct TALER_Amount *wire_fee, - unsigned int details_length, - const struct TALER_TrackTransferDetails *details) + unsigned int http_status, + enum TALER_ErrorCode ec, + const struct TALER_ExchangePublicKeyP *exchange_pub, + const json_t *json, + const struct GNUNET_HashCode *h_wire, + struct GNUNET_TIME_Absolute execution_time, + const struct TALER_Amount *total_amount, + const struct TALER_Amount *wire_fee, + unsigned int details_length, + const struct TALER_TrackTransferDetails *details) { struct TrackTransferState *tts = cls; struct TALER_TESTING_Interpreter *is = tts->is; @@ -598,8 +598,8 @@ track_transfer_cb struct GNUNET_HashCode h_wire_details; if (NULL == (wire_details_cmd - = TALER_TESTING_interpreter_lookup_command - (is, tts->wire_details_reference))) + = TALER_TESTING_interpreter_lookup_command + (is, tts->wire_details_reference))) { GNUNET_break (0); TALER_TESTING_interpreter_fail (is); @@ -618,8 +618,8 @@ track_transfer_cb GNUNET_assert (GNUNET_OK == - TALER_JSON_merchant_wire_signature_hash (wire_details, - &h_wire_details)); + TALER_JSON_merchant_wire_signature_hash (wire_details, + &h_wire_details)); if (0 != GNUNET_memcmp (&h_wire_details, h_wire)) @@ -639,8 +639,8 @@ track_transfer_cb struct TALER_Amount total_amount_from_reference; if (NULL == (total_amount_cmd - = TALER_TESTING_interpreter_lookup_command - (is, tts->total_amount_reference))) + = TALER_TESTING_interpreter_lookup_command + (is, tts->total_amount_reference))) { GNUNET_break (0); TALER_TESTING_interpreter_fail (is); @@ -648,7 +648,7 @@ track_transfer_cb } if (GNUNET_OK != TALER_TESTING_get_trait_amount - (total_amount_cmd, 0, &total_amount_from_reference_str)) + (total_amount_cmd, 0, &total_amount_from_reference_str)) { GNUNET_break (0); TALER_TESTING_interpreter_fail (is); @@ -656,8 +656,8 @@ track_transfer_cb } GNUNET_assert (GNUNET_OK == TALER_string_to_amount - (total_amount_from_reference_str, - &total_amount_from_reference)); + (total_amount_from_reference_str, + &total_amount_from_reference)); if (0 != TALER_amount_cmp (total_amount, &total_amount_from_reference)) @@ -702,7 +702,7 @@ track_transfer_run (void *cls, const struct TALER_TESTING_Command *wtid_cmd; wtid_cmd = TALER_TESTING_interpreter_lookup_command - (tts->is, tts->wtid_reference); + (tts->is, tts->wtid_reference); if (NULL == wtid_cmd) { @@ -712,7 +712,7 @@ track_transfer_run (void *cls, } if (GNUNET_OK != TALER_TESTING_get_trait_wtid - (wtid_cmd, tts->index, &wtid_ptr)) + (wtid_cmd, tts->index, &wtid_ptr)) { GNUNET_break (0); TALER_TESTING_interpreter_fail (tts->is); @@ -747,9 +747,9 @@ track_transfer_run (void *cls, struct TALER_TESTING_Command TALER_TESTING_cmd_track_transfer_empty (const char *label, - const char *wtid_reference, - unsigned int index, - unsigned int expected_response_code) + const char *wtid_reference, + unsigned int index, + unsigned int expected_response_code) { struct TrackTransferState *tts; @@ -788,11 +788,11 @@ TALER_TESTING_cmd_track_transfer_empty struct TALER_TESTING_Command TALER_TESTING_cmd_track_transfer (const char *label, - const char *wtid_reference, - unsigned int index, - unsigned int expected_response_code, - const char *expected_total_amount, - const char *expected_wire_fee) + const char *wtid_reference, + unsigned int index, + unsigned int expected_response_code, + const char *expected_total_amount, + const char *expected_wire_fee) { struct TrackTransferState *tts; diff --git a/src/lib/testing_api_cmd_wire.c b/src/lib/testing_api_cmd_wire.c index 113545499..e2a8d7f1f 100644 --- a/src/lib/testing_api_cmd_wire.c +++ b/src/lib/testing_api_cmd_wire.c @@ -85,7 +85,7 @@ struct WireState static void wire_cb (void *cls, unsigned int http_status, - enum TALER_ErrorCode ec, + enum TALER_ErrorCode ec, unsigned int accounts_len, const struct TALER_EXCHANGE_WireAccount *accounts) { @@ -105,7 +105,7 @@ wire_cb (void *cls, if (MHD_HTTP_OK == http_status) { - for (unsigned int i=0;iexpected_fee, - &expected_fee)); - const struct TALER_EXCHANGE_WireAggregateFees *waf; + TALER_string_to_amount (ws->expected_fee, + &expected_fee)); + const struct TALER_EXCHANGE_WireAggregateFees *waf; for (waf = accounts[i].fees; NULL != waf; waf = waf->next) diff --git a/src/lib/testing_api_cmd_withdraw.c b/src/lib/testing_api_cmd_withdraw.c index 41cd22249..92b587b5a 100644 --- a/src/lib/testing_api_cmd_withdraw.c +++ b/src/lib/testing_api_cmd_withdraw.c @@ -133,8 +133,8 @@ do_retry (void *cls) ws->retry_task = NULL; withdraw_run (ws, - NULL, - ws->is); + NULL, + ws->is); } @@ -152,7 +152,7 @@ do_retry (void *cls) static void reserve_withdraw_cb (void *cls, unsigned int http_status, - enum TALER_ErrorCode ec, + enum TALER_ErrorCode ec, const struct TALER_DenominationSignature *sig, const json_t *full_response) { @@ -166,23 +166,23 @@ reserve_withdraw_cb (void *cls, { if ( (0 == http_status) || (TALER_EC_DB_COMMIT_FAILED_ON_RETRY == ec) || - (TALER_EC_WITHDRAW_INSUFFICIENT_FUNDS == ec) || - (TALER_EC_WITHDRAW_RESERVE_UNKNOWN == ec) || - (MHD_HTTP_INTERNAL_SERVER_ERROR == http_status) ) + (TALER_EC_WITHDRAW_INSUFFICIENT_FUNDS == ec) || + (TALER_EC_WITHDRAW_RESERVE_UNKNOWN == ec) || + (MHD_HTTP_INTERNAL_SERVER_ERROR == http_status) ) { GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Retrying withdraw failed with %u/%d\n", http_status, (int) ec); - /* on DB conflicts, do not use backoff */ - if (TALER_EC_DB_COMMIT_FAILED_ON_RETRY == ec) - ws->backoff = GNUNET_TIME_UNIT_ZERO; - else - ws->backoff = EXCHANGE_LIB_BACKOFF (ws->backoff); - ws->retry_task = GNUNET_SCHEDULER_add_delayed (ws->backoff, - &do_retry, - ws); - return; + /* on DB conflicts, do not use backoff */ + if (TALER_EC_DB_COMMIT_FAILED_ON_RETRY == ec) + ws->backoff = GNUNET_TIME_UNIT_ZERO; + else + ws->backoff = EXCHANGE_LIB_BACKOFF (ws->backoff); + ws->retry_task = GNUNET_SCHEDULER_add_delayed (ws->backoff, + &do_retry, + ws); + return; } } GNUNET_log (GNUNET_ERROR_TYPE_ERROR, @@ -244,7 +244,7 @@ withdraw_run (void *cls, (void) cmd; create_reserve = TALER_TESTING_interpreter_lookup_command - (is, ws->reserve_reference); + (is, ws->reserve_reference); if (NULL == create_reserve) { GNUNET_break (0); @@ -264,8 +264,8 @@ withdraw_run (void *cls, ws->is = is; ws->pk = TALER_TESTING_find_pk - (TALER_EXCHANGE_get_keys (is->exchange), - &ws->amount); + (TALER_EXCHANGE_get_keys (is->exchange), + &ws->amount); if (NULL == ws->pk) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, @@ -349,7 +349,7 @@ withdraw_traits (void *cls, /* We offer the reserve key where these coins were withdrawn * from. */ reserve_cmd = TALER_TESTING_interpreter_lookup_command - (ws->is, ws->reserve_reference); + (ws->is, ws->reserve_reference); if (NULL == reserve_cmd) { @@ -359,7 +359,7 @@ withdraw_traits (void *cls, } if (GNUNET_OK != TALER_TESTING_get_trait_reserve_priv - (reserve_cmd, 0, &reserve_priv)) + (reserve_cmd, 0, &reserve_priv)) { GNUNET_break (0); TALER_TESTING_interpreter_fail (ws->is); @@ -407,9 +407,9 @@ withdraw_traits (void *cls, struct TALER_TESTING_Command TALER_TESTING_cmd_withdraw_amount (const char *label, - const char *reserve_reference, - const char *amount, - unsigned int expected_response_code) + const char *reserve_reference, + const char *amount, + unsigned int expected_response_code) { struct WithdrawState *ws; @@ -457,9 +457,9 @@ TALER_TESTING_cmd_withdraw_amount struct TALER_TESTING_Command TALER_TESTING_cmd_withdraw_denomination (const char *label, - const char *reserve_reference, - const struct TALER_EXCHANGE_DenomPublicKey *dk, - unsigned int expected_response_code) + const char *reserve_reference, + const struct TALER_EXCHANGE_DenomPublicKey *dk, + unsigned int expected_response_code) { struct WithdrawState *ws; diff --git a/src/lib/testing_api_helpers.c b/src/lib/testing_api_helpers.c index 0f2575d98..84221c065 100644 --- a/src/lib/testing_api_helpers.c +++ b/src/lib/testing_api_helpers.c @@ -41,8 +41,8 @@ TALER_TESTING_cleanup_files (const char *config_name) { if (GNUNET_OK != GNUNET_CONFIGURATION_parse_and_run (config_name, - &TALER_TESTING_cleanup_files_cfg, - NULL)) + &TALER_TESTING_cleanup_files_cfg, + NULL)) exit (77); } @@ -56,19 +56,19 @@ TALER_TESTING_cleanup_files (const char *config_name) */ int TALER_TESTING_cleanup_files_cfg (void *cls, - const struct GNUNET_CONFIGURATION_Handle *cfg) + const struct GNUNET_CONFIGURATION_Handle *cfg) { char *dir; if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg, - "exchange", - "keydir", - &dir)) + "exchange", + "keydir", + &dir)) { GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, - "exchange", - "keydir"); + "exchange", + "keydir"); return GNUNET_SYSERR; } if (GNUNET_YES == @@ -91,7 +91,7 @@ TALER_TESTING_cleanup_files_cfg (void *cls, */ int TALER_TESTING_run_keyup (const char *config_filename, - const char *output_filename) + const char *output_filename) { struct GNUNET_OS_Process *proc; @@ -106,7 +106,7 @@ TALER_TESTING_run_keyup (const char *config_filename, if (NULL == proc) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Failed to run `taler-exchange-keyup`, is your PATH correct?\n"); + "Failed to run `taler-exchange-keyup`, is your PATH correct?\n"); return GNUNET_SYSERR; } GNUNET_OS_process_wait (proc); @@ -127,10 +127,10 @@ TALER_TESTING_run_keyup (const char *config_filename, */ int TALER_TESTING_run_auditor_sign (const char *config_filename, - const char *exchange_master_pub, - const char *auditor_base_url, - const char *signdata_in, - const char *signdata_out) + const char *exchange_master_pub, + const char *auditor_base_url, + const char *signdata_in, + const char *signdata_out) { struct GNUNET_OS_Process *proc; @@ -148,7 +148,7 @@ TALER_TESTING_run_auditor_sign (const char *config_filename, if (NULL == proc) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Failed to run `taler-auditor-sign`, is your PATH correct?\n"); + "Failed to run `taler-auditor-sign`, is your PATH correct?\n"); return GNUNET_SYSERR; } GNUNET_OS_process_wait (proc); @@ -195,7 +195,7 @@ TALER_TESTING_run_auditor_exchange (const char *config_filename, if (NULL == proc) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Failed to run `taler-auditor-exchange`, is your PATH correct?\n"); + "Failed to run `taler-auditor-exchange`, is your PATH correct?\n"); return GNUNET_SYSERR; } GNUNET_assert (GNUNET_OK == @@ -207,7 +207,7 @@ TALER_TESTING_run_auditor_exchange (const char *config_filename, (GNUNET_OS_PROCESS_EXITED != type) ) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "taler-auditor-exchange terminated with error (%d/%d)\n", + "taler-auditor-exchange terminated with error (%d/%d)\n", (int) type, (int) code); return GNUNET_SYSERR; @@ -240,7 +240,7 @@ TALER_TESTING_exchange_db_reset (const char *config_filename) if (NULL == proc) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Failed to run `taler-exchange-dbinit`, is your PATH correct?\n"); + "Failed to run `taler-exchange-dbinit`, is your PATH correct?\n"); return GNUNET_NO; } if (GNUNET_SYSERR == @@ -257,7 +257,7 @@ TALER_TESTING_exchange_db_reset (const char *config_filename) (0 != code) ) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Failed to setup (exchange) database, exit code %d\n", + "Failed to setup (exchange) database, exit code %d\n", (int) code); return GNUNET_NO; } @@ -265,7 +265,7 @@ TALER_TESTING_exchange_db_reset (const char *config_filename) (0 != code) ) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Unexpected error (%d/%d) running `taler-exchange-dbinit'!\n", + "Unexpected error (%d/%d) running `taler-exchange-dbinit'!\n", (int) type, (int) code); return GNUNET_SYSERR; @@ -298,7 +298,7 @@ TALER_TESTING_auditor_db_reset (const char *config_filename) if (NULL == proc) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Failed to run `taler-auditor-dbinit`, is your PATH correct?\n"); + "Failed to run `taler-auditor-dbinit`, is your PATH correct?\n"); return GNUNET_NO; } if (GNUNET_SYSERR == @@ -315,7 +315,7 @@ TALER_TESTING_auditor_db_reset (const char *config_filename) (0 != code) ) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Failed to setup (auditor) database, exit code %d\n", + "Failed to setup (auditor) database, exit code %d\n", (int) code); return GNUNET_NO; } @@ -323,7 +323,7 @@ TALER_TESTING_auditor_db_reset (const char *config_filename) (0 != code) ) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Unexpected error (%d/%d) running `taler-auditor-dbinit'!\n", + "Unexpected error (%d/%d) running `taler-auditor-dbinit'!\n", (int) type, (int) code); return GNUNET_SYSERR; @@ -373,7 +373,7 @@ struct SignInfo */ static int sign_keys_for_exchange (void *cls, - const struct GNUNET_CONFIGURATION_Handle *cfg) + const struct GNUNET_CONFIGURATION_Handle *cfg) { struct SignInfo *si = cls; char *test_home_dir; @@ -460,10 +460,10 @@ sign_keys_for_exchange (void *cls, if (GNUNET_OK != TALER_TESTING_run_auditor_sign (si->config_filename, - exchange_master_pub, - si->auditor_base_url, - si->auditor_sign_input_filename, - signed_keys_out)) + exchange_master_pub, + si->auditor_base_url, + si->auditor_sign_input_filename, + signed_keys_out)) { GNUNET_free (si->exchange_base_url); GNUNET_free (si->auditor_base_url); @@ -495,8 +495,8 @@ sign_keys_for_exchange (void *cls, */ int TALER_TESTING_prepare_exchange (const char *config_filename, - char **auditor_base_url, - char **exchange_base_url) + char **auditor_base_url, + char **exchange_base_url) { struct SignInfo si = { .config_filename = config_filename, @@ -507,7 +507,7 @@ TALER_TESTING_prepare_exchange (const char *config_filename, if (GNUNET_OK != TALER_TESTING_run_keyup (config_filename, - si.auditor_sign_input_filename)) + si.auditor_sign_input_filename)) return GNUNET_NO; if (GNUNET_OK != TALER_TESTING_exchange_db_reset (config_filename)) @@ -517,8 +517,8 @@ TALER_TESTING_prepare_exchange (const char *config_filename, return GNUNET_NO; if (GNUNET_OK != GNUNET_CONFIGURATION_parse_and_run (config_filename, - &sign_keys_for_exchange, - &si)) + &sign_keys_for_exchange, + &si)) return GNUNET_NO; *exchange_base_url = si.exchange_base_url; *auditor_base_url = si.auditor_base_url; @@ -542,7 +542,7 @@ TALER_TESTING_find_pk (const struct TALER_EXCHANGE_Keys *keys, char *str; now = GNUNET_TIME_absolute_get (); - for (unsigned int i=0;inum_denom_keys;i++) + for (unsigned int i = 0; inum_denom_keys; i++) { pk = &keys->denom_keys[i]; if ( (0 == TALER_amount_cmp (amount, @@ -555,7 +555,7 @@ TALER_TESTING_find_pk (const struct TALER_EXCHANGE_Keys *keys, /* do 2nd pass to check if expiration times are to blame for * failure */ str = TALER_amount_to_string (amount); - for (unsigned int i=0;inum_denom_keys;i++) + for (unsigned int i = 0; inum_denom_keys; i++) { pk = &keys->denom_keys[i]; if ( (0 == TALER_amount_cmp (amount, @@ -566,13 +566,13 @@ TALER_TESTING_find_pk (const struct TALER_EXCHANGE_Keys *keys, { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - "Have denomination key for `%s', but with wrong" - " expiration range %llu vs [%llu,%llu)\n", - str, - (unsigned long long) now.abs_value_us, - (unsigned long long) pk->valid_from.abs_value_us, - (unsigned long long) - pk->withdraw_valid_until.abs_value_us); + "Have denomination key for `%s', but with wrong" + " expiration range %llu vs [%llu,%llu)\n", + str, + (unsigned long long) now.abs_value_us, + (unsigned long long) pk->valid_from.abs_value_us, + (unsigned long long) + pk->withdraw_valid_until.abs_value_us); GNUNET_free (str); return NULL; } @@ -609,18 +609,18 @@ TALER_TESTING_wait_exchange_ready (const char *base_url) wget_cmd); iter = 0; do + { + if (10 == iter) { - if (10 == iter) - { - fprintf (stderr, - "Failed to launch `taler-exchange-httpd' (or `wget')\n"); - GNUNET_free (wget_cmd); - return 77; - } - fprintf (stderr, ".\n"); - sleep (1); - iter++; + fprintf (stderr, + "Failed to launch `taler-exchange-httpd' (or `wget')\n"); + GNUNET_free (wget_cmd); + return 77; } + fprintf (stderr, ".\n"); + sleep (1); + iter++; + } while (0 != system (wget_cmd)); GNUNET_free (wget_cmd); return 0; @@ -650,18 +650,18 @@ TALER_TESTING_wait_auditor_ready (const char *base_url) "Waiting for `taler-auditor-httpd' to be ready\n"); iter = 0; do + { + if (10 == iter) { - if (10 == iter) - { - fprintf (stderr, - "Failed to launch `taler-auditor-httpd' (or `wget')\n"); - GNUNET_free (wget_cmd); - return 77; - } - fprintf (stderr, ".\n"); - sleep (1); - iter++; + fprintf (stderr, + "Failed to launch `taler-auditor-httpd' (or `wget')\n"); + GNUNET_free (wget_cmd); + return 77; } + fprintf (stderr, ".\n"); + sleep (1); + iter++; + } while (0 != system (wget_cmd)); GNUNET_free (wget_cmd); return 0; @@ -695,7 +695,8 @@ TALER_TESTING_setup_with_exchange (TALER_TESTING_Main main_cb, if (GNUNET_OK != (result = GNUNET_CONFIGURATION_parse_and_run (config_filename, - &TALER_TESTING_setup_with_exchange_cfg, + & + TALER_TESTING_setup_with_exchange_cfg, &setup_ctx))) return result; return GNUNET_OK; @@ -713,7 +714,8 @@ TALER_TESTING_setup_with_exchange (TALER_TESTING_Main main_cb, */ int TALER_TESTING_setup_with_exchange_cfg (void *cls, - const struct GNUNET_CONFIGURATION_Handle *cfg) + const struct + GNUNET_CONFIGURATION_Handle *cfg) { const struct TALER_TESTING_SetupContext *setup_ctx = cls; struct GNUNET_OS_Process *exchanged; @@ -751,7 +753,7 @@ TALER_TESTING_setup_with_exchange_cfg (void *cls, if (GNUNET_OK != GNUNET_NETWORK_test_port_free (IPPROTO_TCP, - (uint16_t) port)) + (uint16_t) port)) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Required port %llu not available, skipping.\n", @@ -816,7 +818,9 @@ TALER_TESTING_setup_with_exchange_cfg (void *cls, */ int TALER_TESTING_setup_with_auditor_and_exchange_cfg (void *cls, - const struct GNUNET_CONFIGURATION_Handle *cfg) + const struct + GNUNET_CONFIGURATION_Handle * + cfg) { const struct TALER_TESTING_SetupContext *setup_ctx = cls; struct GNUNET_OS_Process *auditord; @@ -854,7 +858,7 @@ TALER_TESTING_setup_with_auditor_and_exchange_cfg (void *cls, if (GNUNET_OK != GNUNET_NETWORK_test_port_free (IPPROTO_TCP, - (uint16_t) port)) + (uint16_t) port)) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Required port %llu not available, skipping.\n", @@ -937,7 +941,8 @@ TALER_TESTING_setup_with_auditor_and_exchange (TALER_TESTING_Main main_cb, }; return GNUNET_CONFIGURATION_parse_and_run (config_file, - &TALER_TESTING_setup_with_auditor_and_exchange_cfg, + & + TALER_TESTING_setup_with_auditor_and_exchange_cfg, &setup_ctx); } @@ -959,7 +964,7 @@ TALER_TESTING_url_port_free (const char *url) pnum = strtol (port + 1, NULL, 10); if (GNUNET_OK != GNUNET_NETWORK_test_port_free (IPPROTO_TCP, - pnum)) + pnum)) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Port %u not available.\n", @@ -989,7 +994,7 @@ TALER_TESTING_make_wire_details (unsigned long long account_no, int ends_slash; if (0 < strlen (bank_url)) - ends_slash = '/' == bank_url[strlen(bank_url)-1]; + ends_slash = '/' == bank_url[strlen (bank_url) - 1]; else ends_slash = 0; @@ -1001,7 +1006,8 @@ TALER_TESTING_make_wire_details (unsigned long long account_no, account_no); ret = json_pack ("{s:s, s:s}", "url", payto, - "salt", "test-salt (must be constant for aggregation tests)"); + "salt", + "test-salt (must be constant for aggregation tests)"); GNUNET_free (payto); return ret; } @@ -1049,9 +1055,9 @@ TALER_TESTING_prepare_fakebank (const char *config_filename, { GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_WARNING, - config_section, - "URL", - "expected `x-taler-bank' payto://-URL"); + config_section, + "URL", + "expected `x-taler-bank' payto://-URL"); GNUNET_CONFIGURATION_destroy (cfg); GNUNET_free (payto_url); return NULL; diff --git a/src/lib/testing_api_loop.c b/src/lib/testing_api_loop.c index bebd159de..38139de25 100644 --- a/src/lib/testing_api_loop.c +++ b/src/lib/testing_api_loop.c @@ -47,7 +47,7 @@ static struct GNUNET_DISK_PipeHandle *sigpipe; const struct TALER_TESTING_Command * TALER_TESTING_interpreter_lookup_command (struct TALER_TESTING_Interpreter *is, - const char *label) + const char *label) { if (NULL == label) { @@ -56,7 +56,7 @@ TALER_TESTING_interpreter_lookup_command return NULL; } /* Search backwards as we most likely reference recent commands */ - for (int i=is->ip; i >= 0; i--) + for (int i = is->ip; i >= 0; i--) { const struct TALER_TESTING_Command *cmd = &is->commands[i]; @@ -75,7 +75,7 @@ TALER_TESTING_interpreter_lookup_command TALER_TESTING_get_trait_cmd (cmd, BATCH_INDEX, &batch)); - for (unsigned int j=0; + for (unsigned int j = 0; NULL != (cmd = &batch[j])->label; j++) { @@ -125,8 +125,8 @@ TALER_TESTING_interpreter_get_fakebank void TALER_TESTING_run_with_fakebank (struct TALER_TESTING_Interpreter *is, - struct TALER_TESTING_Command *commands, - const char *bank_url) + struct TALER_TESTING_Command *commands, + const char *bank_url) { const char *port; long pnum; @@ -183,8 +183,9 @@ TALER_TESTING_interpreter_next (struct TALER_TESTING_Interpreter *is) if (0 != ipc) GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, "Interpreter executed 1000 instructions in %s\n", - GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_duration (last_report), - GNUNET_YES)); + GNUNET_STRINGS_relative_time_to_string ( + GNUNET_TIME_absolute_get_duration (last_report), + GNUNET_YES)); last_report = GNUNET_TIME_absolute_get (); } ipc++; @@ -208,12 +209,12 @@ TALER_TESTING_interpreter_fail "Failed at command `%s'\n", cmd->label); while (TALER_TESTING_cmd_is_batch (cmd)) - { - cmd = TALER_TESTING_cmd_batch_get_current (cmd); - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Batch is at command `%s'\n", - cmd->label); - } + { + cmd = TALER_TESTING_cmd_batch_get_current (cmd); + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Batch is at command `%s'\n", + cmd->label); + } is->result = GNUNET_SYSERR; GNUNET_SCHEDULER_shutdown (); } @@ -301,7 +302,7 @@ do_shutdown (void *cls) "Executing shutdown at `%s'\n", label); - for (unsigned int j=0; + for (unsigned int j = 0; NULL != (cmd = &is->commands[j])->label; j++) cmd->cleanup (cmd->cls, @@ -433,7 +434,7 @@ maint_child_death (void *cls) GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Triggering key state reload at exchange\n"); GNUNET_break (0 == GNUNET_OS_process_kill - (is->exchanged, SIGUSR1)); + (is->exchanged, SIGUSR1)); sleep (5); /* make sure signal was received and processed */ } } @@ -490,16 +491,16 @@ TALER_TESTING_run2 (struct TALER_TESTING_Interpreter *is, is->timeout_task = NULL; } /* get the number of commands */ - for (i=0;NULL != commands[i].label;i++) ; + for (i = 0; NULL != commands[i].label; i++); is->commands = GNUNET_new_array (i + 1, struct TALER_TESTING_Command); memcpy (is->commands, commands, sizeof (struct TALER_TESTING_Command) * i); is->timeout_task = GNUNET_SCHEDULER_add_delayed - (timeout, - &do_timeout, - is); + (timeout, + &do_timeout, + is); GNUNET_SCHEDULER_add_shutdown (&do_shutdown, is); is->task = GNUNET_SCHEDULER_add_now (&interpreter_run, is); } @@ -570,12 +571,13 @@ static void sighandler_child_death () { static char c; - int old_errno = errno; /* back-up errno */ + int old_errno = errno; /* back-up errno */ GNUNET_break (1 == GNUNET_DISK_file_write - (GNUNET_DISK_pipe_handle (sigpipe, GNUNET_DISK_PIPE_END_WRITE), - &c, sizeof (c))); - errno = old_errno; /* restore errno */ + (GNUNET_DISK_pipe_handle (sigpipe, + GNUNET_DISK_PIPE_END_WRITE), + &c, sizeof (c))); + errno = old_errno; /* restore errno */ } @@ -591,8 +593,8 @@ sighandler_child_death () void TALER_TESTING_cert_cb (void *cls, - const struct TALER_EXCHANGE_Keys *keys, - enum TALER_EXCHANGE_VersionCompatibility compat) + const struct TALER_EXCHANGE_Keys *keys, + enum TALER_EXCHANGE_VersionCompatibility compat) { struct MainContext *main_ctx = cls; struct TALER_TESTING_Interpreter *is = main_ctx->is; @@ -603,23 +605,23 @@ TALER_TESTING_cert_cb { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - "Got NULL response for /keys" - " during startup, retrying!\n"); + "Got NULL response for /keys" + " during startup, retrying!\n"); TALER_EXCHANGE_disconnect (is->exchange); GNUNET_assert (NULL != (is->exchange = TALER_EXCHANGE_connect - (is->ctx, - main_ctx->exchange_url, - &TALER_TESTING_cert_cb, - main_ctx, - TALER_EXCHANGE_OPTION_END))); + (is->ctx, + main_ctx->exchange_url, + &TALER_TESTING_cert_cb, + main_ctx, + TALER_EXCHANGE_OPTION_END))); return; } else GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Got NULL response for /keys" - " during execution!\n"); + "Got NULL response for /keys" + " during execution!\n"); } else { @@ -705,7 +707,7 @@ do_abort (void *cls) static int main_exchange_connect_with_cfg (void *cls, - const struct GNUNET_CONFIGURATION_Handle *cfg) + const struct GNUNET_CONFIGURATION_Handle *cfg) { struct MainContext *main_ctx = cls; struct TALER_TESTING_Interpreter *is = main_ctx->is; @@ -725,14 +727,14 @@ main_exchange_connect_with_cfg main_ctx->exchange_url = exchange_url; is->cfg = cfg; is->timeout_task = GNUNET_SCHEDULER_add_shutdown (&do_abort, - main_ctx); + main_ctx); GNUNET_break (NULL != (is->exchange = TALER_EXCHANGE_connect - (is->ctx, - exchange_url, - &TALER_TESTING_cert_cb, - main_ctx, - TALER_EXCHANGE_OPTION_END))); + (is->ctx, + exchange_url, + &TALER_TESTING_cert_cb, + main_ctx, + TALER_EXCHANGE_OPTION_END))); is->cfg = NULL; return GNUNET_OK; } @@ -751,7 +753,8 @@ main_wrapper_exchange_connect (void *cls) GNUNET_break (GNUNET_OK == GNUNET_CONFIGURATION_parse_and_run (main_ctx->config_filename, - &main_exchange_connect_with_cfg, + & + main_exchange_connect_with_cfg, main_ctx)); } @@ -802,11 +805,11 @@ TALER_TESTING_setup (TALER_TESTING_Main main_cb, GNUNET_NO, GNUNET_NO); GNUNET_assert (NULL != sigpipe); shc_chld = GNUNET_SIGNAL_handler_install - (GNUNET_SIGCHLD, - &sighandler_child_death); + (GNUNET_SIGCHLD, + &sighandler_child_death); is.ctx = GNUNET_CURL_init - (&GNUNET_CURL_gnunet_scheduler_reschedule, - &is.rc); + (&GNUNET_CURL_gnunet_scheduler_reschedule, + &is.rc); GNUNET_CURL_enable_async_scope_header (is.ctx, "Taler-Correlation-Id"); GNUNET_assert (NULL != is.ctx); is.rc = GNUNET_CURL_gnunet_rc_create (is.ctx); @@ -817,8 +820,8 @@ TALER_TESTING_setup (TALER_TESTING_Main main_cb, GNUNET_SCHEDULER_run (&main_wrapper_exchange_connect, &main_ctx); else - GNUNET_SCHEDULER_run (&main_wrapper_exchange_agnostic, - &main_ctx); + GNUNET_SCHEDULER_run (&main_wrapper_exchange_agnostic, + &main_ctx); if (NULL != is.final_cleanup_cb) is.final_cleanup_cb (is.final_cleanup_cb_cls); GNUNET_free_non_null (main_ctx.exchange_url); diff --git a/src/lib/testing_api_trait_amount.c b/src/lib/testing_api_trait_amount.c index 8f2b79d45..962948bc5 100644 --- a/src/lib/testing_api_trait_amount.c +++ b/src/lib/testing_api_trait_amount.c @@ -45,8 +45,8 @@ int TALER_TESTING_get_trait_amount_obj (const struct TALER_TESTING_Command *cmd, - unsigned int index, - const struct TALER_Amount **amount) + unsigned int index, + const struct TALER_Amount **amount) { return cmd->traits (cmd->cls, (const void **) amount, @@ -67,7 +67,7 @@ TALER_TESTING_get_trait_amount_obj struct TALER_TESTING_Trait TALER_TESTING_make_trait_amount_obj (unsigned int index, - const struct TALER_Amount *amount) + const struct TALER_Amount *amount) { struct TALER_TESTING_Trait ret = { .index = index, diff --git a/src/lib/testing_api_trait_blinding_key.c b/src/lib/testing_api_trait_blinding_key.c index 6e52d1148..b723e5cfc 100644 --- a/src/lib/testing_api_trait_blinding_key.c +++ b/src/lib/testing_api_trait_blinding_key.c @@ -44,8 +44,8 @@ int TALER_TESTING_get_trait_blinding_key (const struct TALER_TESTING_Command *cmd, - unsigned int index, - const struct TALER_DenominationBlindingKeyP **blinding_key) + unsigned int index, + const struct TALER_DenominationBlindingKeyP **blinding_key) { return cmd->traits (cmd->cls, (const void **) blinding_key, @@ -66,7 +66,7 @@ TALER_TESTING_get_trait_blinding_key struct TALER_TESTING_Trait TALER_TESTING_make_trait_blinding_key (unsigned int index, - const struct TALER_DenominationBlindingKeyP *blinding_key) + const struct TALER_DenominationBlindingKeyP *blinding_key) { struct TALER_TESTING_Trait ret = { .index = index, diff --git a/src/lib/testing_api_trait_cmd.c b/src/lib/testing_api_trait_cmd.c index 61e976568..faf8799be 100644 --- a/src/lib/testing_api_trait_cmd.c +++ b/src/lib/testing_api_trait_cmd.c @@ -46,8 +46,8 @@ int TALER_TESTING_get_trait_cmd (const struct TALER_TESTING_Command *cmd, - unsigned int index, - struct TALER_TESTING_Command **_cmd) + unsigned int index, + struct TALER_TESTING_Command **_cmd) { return cmd->traits (cmd->cls, (const void **) _cmd, @@ -69,7 +69,7 @@ TALER_TESTING_get_trait_cmd struct TALER_TESTING_Trait TALER_TESTING_make_trait_cmd (unsigned int index, - const struct TALER_TESTING_Command *cmd) + const struct TALER_TESTING_Command *cmd) { struct TALER_TESTING_Trait ret = { .index = index, diff --git a/src/lib/testing_api_trait_coin_priv.c b/src/lib/testing_api_trait_coin_priv.c index b06e4a207..85331de7e 100644 --- a/src/lib/testing_api_trait_coin_priv.c +++ b/src/lib/testing_api_trait_coin_priv.c @@ -44,8 +44,8 @@ int TALER_TESTING_get_trait_coin_priv (const struct TALER_TESTING_Command *cmd, - unsigned int index, - const struct TALER_CoinSpendPrivateKeyP **coin_priv) + unsigned int index, + const struct TALER_CoinSpendPrivateKeyP **coin_priv) { return cmd->traits (cmd->cls, (const void **) coin_priv, @@ -64,7 +64,7 @@ TALER_TESTING_get_trait_coin_priv struct TALER_TESTING_Trait TALER_TESTING_make_trait_coin_priv (unsigned int index, - const struct TALER_CoinSpendPrivateKeyP *coin_priv) + const struct TALER_CoinSpendPrivateKeyP *coin_priv) { struct TALER_TESTING_Trait ret = { .index = index, diff --git a/src/lib/testing_api_trait_denom_pub.c b/src/lib/testing_api_trait_denom_pub.c index 8bc482176..b11c459ee 100644 --- a/src/lib/testing_api_trait_denom_pub.c +++ b/src/lib/testing_api_trait_denom_pub.c @@ -44,8 +44,8 @@ int TALER_TESTING_get_trait_denom_pub (const struct TALER_TESTING_Command *cmd, - unsigned int index, - const struct TALER_EXCHANGE_DenomPublicKey **denom_pub) + unsigned int index, + const struct TALER_EXCHANGE_DenomPublicKey **denom_pub) { return cmd->traits (cmd->cls, (const void **) denom_pub, @@ -64,7 +64,7 @@ TALER_TESTING_get_trait_denom_pub struct TALER_TESTING_Trait TALER_TESTING_make_trait_denom_pub (unsigned int index, - const struct TALER_EXCHANGE_DenomPublicKey *denom_pub) + const struct TALER_EXCHANGE_DenomPublicKey *denom_pub) { struct TALER_TESTING_Trait ret = { .index = index, diff --git a/src/lib/testing_api_trait_denom_sig.c b/src/lib/testing_api_trait_denom_sig.c index 03062c835..83c19cb82 100644 --- a/src/lib/testing_api_trait_denom_sig.c +++ b/src/lib/testing_api_trait_denom_sig.c @@ -44,8 +44,8 @@ int TALER_TESTING_get_trait_denom_sig (const struct TALER_TESTING_Command *cmd, - unsigned int index, - const struct TALER_DenominationSignature **denom_sig) + unsigned int index, + const struct TALER_DenominationSignature **denom_sig) { return cmd->traits (cmd->cls, (const void **) denom_sig, @@ -65,7 +65,7 @@ TALER_TESTING_get_trait_denom_sig struct TALER_TESTING_Trait TALER_TESTING_make_trait_denom_sig (unsigned int index, - const struct TALER_DenominationSignature *denom_sig) + const struct TALER_DenominationSignature *denom_sig) { struct TALER_TESTING_Trait ret = { .index = index, diff --git a/src/lib/testing_api_trait_exchange_pub.c b/src/lib/testing_api_trait_exchange_pub.c index e8cdfbb35..711d56f0c 100644 --- a/src/lib/testing_api_trait_exchange_pub.c +++ b/src/lib/testing_api_trait_exchange_pub.c @@ -42,8 +42,8 @@ int TALER_TESTING_get_trait_exchange_pub (const struct TALER_TESTING_Command *cmd, - unsigned int index, - const struct TALER_ExchangePublicKeyP **exchange_pub) + unsigned int index, + const struct TALER_ExchangePublicKeyP **exchange_pub) { return cmd->traits (cmd->cls, (const void **) exchange_pub, @@ -63,7 +63,7 @@ TALER_TESTING_get_trait_exchange_pub struct TALER_TESTING_Trait TALER_TESTING_make_trait_exchange_pub (unsigned int index, - const struct TALER_ExchangePublicKeyP *exchange_pub) + const struct TALER_ExchangePublicKeyP *exchange_pub) { struct TALER_TESTING_Trait ret = { .index = index, diff --git a/src/lib/testing_api_trait_exchange_sig.c b/src/lib/testing_api_trait_exchange_sig.c index 97ce2d969..c7ed29b2c 100644 --- a/src/lib/testing_api_trait_exchange_sig.c +++ b/src/lib/testing_api_trait_exchange_sig.c @@ -42,8 +42,8 @@ int TALER_TESTING_get_trait_exchange_sig (const struct TALER_TESTING_Command *cmd, - unsigned int index, - const struct TALER_ExchangeSignatureP **exchange_sig) + unsigned int index, + const struct TALER_ExchangeSignatureP **exchange_sig) { return cmd->traits (cmd->cls, (const void **) exchange_sig, @@ -63,7 +63,7 @@ TALER_TESTING_get_trait_exchange_sig struct TALER_TESTING_Trait TALER_TESTING_make_trait_exchange_sig (unsigned int index, - const struct TALER_ExchangeSignatureP *exchange_sig) + const struct TALER_ExchangeSignatureP *exchange_sig) { struct TALER_TESTING_Trait ret = { .index = index, diff --git a/src/lib/testing_api_trait_fresh_coin.c b/src/lib/testing_api_trait_fresh_coin.c index 464e7e74c..92d6d4b9c 100644 --- a/src/lib/testing_api_trait_fresh_coin.c +++ b/src/lib/testing_api_trait_fresh_coin.c @@ -43,8 +43,8 @@ int TALER_TESTING_get_trait_fresh_coins (const struct TALER_TESTING_Command *cmd, - unsigned int index, - const struct TALER_TESTING_FreshCoinData **fresh_coins) + unsigned int index, + const struct TALER_TESTING_FreshCoinData **fresh_coins) { return cmd->traits (cmd->cls, (const void **) fresh_coins, @@ -66,7 +66,7 @@ TALER_TESTING_get_trait_fresh_coins struct TALER_TESTING_Trait TALER_TESTING_make_trait_fresh_coins (unsigned int index, - struct TALER_TESTING_FreshCoinData *fresh_coins) + struct TALER_TESTING_FreshCoinData *fresh_coins) { struct TALER_TESTING_Trait ret = { .index = index, diff --git a/src/lib/testing_api_trait_json.c b/src/lib/testing_api_trait_json.c index 5f6647fbb..5307dc370 100644 --- a/src/lib/testing_api_trait_json.c +++ b/src/lib/testing_api_trait_json.c @@ -43,8 +43,8 @@ int TALER_TESTING_get_trait_exchange_keys (const struct TALER_TESTING_Command *cmd, - unsigned int index, - const json_t **keys) + unsigned int index, + const json_t **keys) { return cmd->traits (cmd->cls, (const void **) keys, @@ -64,7 +64,7 @@ TALER_TESTING_get_trait_exchange_keys struct TALER_TESTING_Trait TALER_TESTING_make_trait_exchange_keys (unsigned int index, - const json_t *keys) + const json_t *keys) { struct TALER_TESTING_Trait ret = { .index = index, @@ -87,8 +87,8 @@ TALER_TESTING_make_trait_exchange_keys int TALER_TESTING_get_trait_wire_details (const struct TALER_TESTING_Command *cmd, - unsigned int index, - const json_t **wire_details) + unsigned int index, + const json_t **wire_details) { return cmd->traits (cmd->cls, (const void **) wire_details, @@ -109,7 +109,7 @@ TALER_TESTING_get_trait_wire_details struct TALER_TESTING_Trait TALER_TESTING_make_trait_wire_details (unsigned int index, - const json_t *wire_details) + const json_t *wire_details) { struct TALER_TESTING_Trait ret = { .index = index, diff --git a/src/lib/testing_api_trait_key_peer.c b/src/lib/testing_api_trait_key_peer.c index d10623d28..f26169eb6 100644 --- a/src/lib/testing_api_trait_key_peer.c +++ b/src/lib/testing_api_trait_key_peer.c @@ -45,8 +45,8 @@ int TALER_TESTING_get_trait_peer_key (const struct TALER_TESTING_Command *cmd, - unsigned int index, - const struct GNUNET_CRYPTO_EddsaPrivateKey **priv) + unsigned int index, + const struct GNUNET_CRYPTO_EddsaPrivateKey **priv) { return cmd->traits (cmd->cls, (const void **) priv, @@ -66,7 +66,7 @@ TALER_TESTING_get_trait_peer_key struct TALER_TESTING_Trait TALER_TESTING_make_trait_peer_key (unsigned int index, - const struct GNUNET_CRYPTO_EddsaPrivateKey *priv) + const struct GNUNET_CRYPTO_EddsaPrivateKey *priv) { struct TALER_TESTING_Trait ret = { .index = index, @@ -91,8 +91,8 @@ TALER_TESTING_make_trait_peer_key int TALER_TESTING_get_trait_peer_key_pub (const struct TALER_TESTING_Command *cmd, - unsigned int index, - const struct GNUNET_CRYPTO_EddsaPublicKey **pub) + unsigned int index, + const struct GNUNET_CRYPTO_EddsaPublicKey **pub) { return cmd->traits (cmd->cls, (const void **) pub, @@ -113,7 +113,7 @@ TALER_TESTING_get_trait_peer_key_pub struct TALER_TESTING_Trait TALER_TESTING_make_trait_peer_key_pub (unsigned int index, - struct GNUNET_CRYPTO_EddsaPublicKey *pub) + struct GNUNET_CRYPTO_EddsaPublicKey *pub) { struct TALER_TESTING_Trait ret = { .index = index, diff --git a/src/lib/testing_api_trait_number.c b/src/lib/testing_api_trait_number.c index ee2e76dbb..b2c545457 100644 --- a/src/lib/testing_api_trait_number.c +++ b/src/lib/testing_api_trait_number.c @@ -43,8 +43,8 @@ int TALER_TESTING_get_trait_uint (const struct TALER_TESTING_Command *cmd, - unsigned int index, - const unsigned int **n) + unsigned int index, + const unsigned int **n) { return cmd->traits (cmd->cls, (const void **) n, @@ -63,7 +63,7 @@ TALER_TESTING_get_trait_uint struct TALER_TESTING_Trait TALER_TESTING_make_trait_uint (unsigned int index, - const unsigned int *n) + const unsigned int *n) { struct TALER_TESTING_Trait ret = { .index = index, @@ -85,8 +85,8 @@ TALER_TESTING_make_trait_uint int TALER_TESTING_get_trait_uint64 (const struct TALER_TESTING_Command *cmd, - unsigned int index, - const uint64_t **n) + unsigned int index, + const uint64_t **n) { return cmd->traits (cmd->cls, (const void **) n, @@ -103,7 +103,7 @@ TALER_TESTING_get_trait_uint64 struct TALER_TESTING_Trait TALER_TESTING_make_trait_uint64 (unsigned int index, - const uint64_t *n) + const uint64_t *n) { struct TALER_TESTING_Trait ret = { .index = index, diff --git a/src/lib/testing_api_trait_process.c b/src/lib/testing_api_trait_process.c index 449b6536f..a35314ef3 100644 --- a/src/lib/testing_api_trait_process.c +++ b/src/lib/testing_api_trait_process.c @@ -47,8 +47,8 @@ int TALER_TESTING_get_trait_process (const struct TALER_TESTING_Command *cmd, - unsigned int index, - struct GNUNET_OS_Process ***processp) + unsigned int index, + struct GNUNET_OS_Process ***processp) { return cmd->traits (cmd->cls, (const void **) processp, @@ -59,7 +59,7 @@ TALER_TESTING_get_trait_process /** * Offer location where a command stores a pointer to a process. - * + * * @param index offered location index number, in case there are * multiple on offer. * @param processp process location to offer. @@ -69,7 +69,7 @@ TALER_TESTING_get_trait_process struct TALER_TESTING_Trait TALER_TESTING_make_trait_process (unsigned int index, - struct GNUNET_OS_Process **processp) + struct GNUNET_OS_Process **processp) { struct TALER_TESTING_Trait ret = { .index = index, diff --git a/src/lib/testing_api_trait_reserve_priv.c b/src/lib/testing_api_trait_reserve_priv.c index 4a619d07f..b920c43d9 100644 --- a/src/lib/testing_api_trait_reserve_priv.c +++ b/src/lib/testing_api_trait_reserve_priv.c @@ -43,8 +43,8 @@ int TALER_TESTING_get_trait_reserve_priv (const struct TALER_TESTING_Command *cmd, - unsigned int index, - const struct TALER_ReservePrivateKeyP **reserve_priv) + unsigned int index, + const struct TALER_ReservePrivateKeyP **reserve_priv) { return cmd->traits (cmd->cls, (const void **) reserve_priv, @@ -63,7 +63,7 @@ TALER_TESTING_get_trait_reserve_priv struct TALER_TESTING_Trait TALER_TESTING_make_trait_reserve_priv (unsigned int index, - const struct TALER_ReservePrivateKeyP *reserve_priv) + const struct TALER_ReservePrivateKeyP *reserve_priv) { struct TALER_TESTING_Trait ret = { .index = index, diff --git a/src/lib/testing_api_trait_string.c b/src/lib/testing_api_trait_string.c index 8b8f511a7..606c6e0b6 100644 --- a/src/lib/testing_api_trait_string.c +++ b/src/lib/testing_api_trait_string.c @@ -48,8 +48,8 @@ int TALER_TESTING_get_trait_contract_terms (const struct TALER_TESTING_Command *cmd, - unsigned int index, - const json_t **contract_terms) + unsigned int index, + const json_t **contract_terms) { return cmd->traits (cmd->cls, (const void **) contract_terms, @@ -67,7 +67,7 @@ TALER_TESTING_get_trait_contract_terms struct TALER_TESTING_Trait TALER_TESTING_make_trait_contract_terms (unsigned int index, - const json_t *contract_terms) + const json_t *contract_terms) { struct TALER_TESTING_Trait ret = { .index = index, @@ -91,8 +91,8 @@ TALER_TESTING_make_trait_contract_terms int TALER_TESTING_get_trait_transfer_subject (const struct TALER_TESTING_Command *cmd, - unsigned int index, - const char **transfer_subject) + unsigned int index, + const char **transfer_subject) { return cmd->traits (cmd->cls, (const void **) transfer_subject, @@ -112,7 +112,7 @@ TALER_TESTING_get_trait_transfer_subject struct TALER_TESTING_Trait TALER_TESTING_make_trait_transfer_subject (unsigned int index, - const char *transfer_subject) + const char *transfer_subject) { struct TALER_TESTING_Trait ret = { .index = index, @@ -136,8 +136,8 @@ TALER_TESTING_make_trait_transfer_subject int TALER_TESTING_get_trait_amount (const struct TALER_TESTING_Command *cmd, - unsigned int index, - const char **amount) + unsigned int index, + const char **amount) { return cmd->traits (cmd->cls, (const void **) amount, @@ -157,7 +157,7 @@ TALER_TESTING_get_trait_amount struct TALER_TESTING_Trait TALER_TESTING_make_trait_amount (unsigned int index, - const char *amount) + const char *amount) { struct TALER_TESTING_Trait ret = { .index = index, @@ -181,8 +181,8 @@ TALER_TESTING_make_trait_amount int TALER_TESTING_get_trait_url (const struct TALER_TESTING_Command *cmd, - unsigned int index, - const char **url) + unsigned int index, + const char **url) { return cmd->traits (cmd->cls, (const void **) url, @@ -202,7 +202,7 @@ TALER_TESTING_get_trait_url struct TALER_TESTING_Trait TALER_TESTING_make_trait_url (unsigned int index, - const char *url) + const char *url) { struct TALER_TESTING_Trait ret = { .index = index, @@ -226,8 +226,8 @@ TALER_TESTING_make_trait_url int TALER_TESTING_get_trait_order_id (const struct TALER_TESTING_Command *cmd, - unsigned int index, - const char **order_id) + unsigned int index, + const char **order_id) { return cmd->traits (cmd->cls, (const void **) order_id, @@ -247,7 +247,7 @@ TALER_TESTING_get_trait_order_id struct TALER_TESTING_Trait TALER_TESTING_make_trait_order_id (unsigned int index, - const char *order_id) + const char *order_id) { struct TALER_TESTING_Trait ret = { .index = index, @@ -271,8 +271,8 @@ TALER_TESTING_make_trait_order_id int TALER_TESTING_get_trait_rejected (const struct TALER_TESTING_Command *cmd, - unsigned int index, - const char **rejected_reference) + unsigned int index, + const char **rejected_reference) { return cmd->traits (cmd->cls, (const void **) rejected_reference, @@ -292,7 +292,7 @@ TALER_TESTING_get_trait_rejected struct TALER_TESTING_Trait TALER_TESTING_make_trait_rejected (unsigned int index, - const char *rejected) + const char *rejected) { struct TALER_TESTING_Trait ret = { .index = index, diff --git a/src/lib/testing_api_trait_time.c b/src/lib/testing_api_trait_time.c index 384ff807d..0cd71ad94 100644 --- a/src/lib/testing_api_trait_time.c +++ b/src/lib/testing_api_trait_time.c @@ -43,8 +43,8 @@ int TALER_TESTING_get_trait_absolute_time (const struct TALER_TESTING_Command *cmd, - unsigned int index, - const struct GNUNET_TIME_Absolute **time) + unsigned int index, + const struct GNUNET_TIME_Absolute **time) { return cmd->traits (cmd->cls, (const void **) time, @@ -62,7 +62,7 @@ TALER_TESTING_get_trait_absolute_time struct TALER_TESTING_Trait TALER_TESTING_make_trait_absolute_time (unsigned int index, - const struct GNUNET_TIME_Absolute *time) + const struct GNUNET_TIME_Absolute *time) { struct TALER_TESTING_Trait ret = { .index = index, diff --git a/src/lib/testing_api_trait_wtid.c b/src/lib/testing_api_trait_wtid.c index 672329713..1353327af 100644 --- a/src/lib/testing_api_trait_wtid.c +++ b/src/lib/testing_api_trait_wtid.c @@ -43,8 +43,8 @@ int TALER_TESTING_get_trait_wtid (const struct TALER_TESTING_Command *cmd, - unsigned int index, - const struct TALER_WireTransferIdentifierRawP **wtid) + unsigned int index, + const struct TALER_WireTransferIdentifierRawP **wtid) { return cmd->traits (cmd->cls, (const void **) wtid, @@ -63,7 +63,7 @@ TALER_TESTING_get_trait_wtid struct TALER_TESTING_Trait TALER_TESTING_make_trait_wtid (unsigned int index, - const struct TALER_WireTransferIdentifierRawP *wtid) + const struct TALER_WireTransferIdentifierRawP *wtid) { struct TALER_TESTING_Trait ret = { .index = index, diff --git a/src/lib/testing_api_traits.c b/src/lib/testing_api_traits.c index aa6c79c83..45e7668ee 100644 --- a/src/lib/testing_api_traits.c +++ b/src/lib/testing_api_traits.c @@ -61,7 +61,7 @@ TALER_TESTING_get_trait (const struct TALER_TESTING_Trait *traits, const char *trait, unsigned int index) { - for (unsigned int i=0; NULL != traits[i].trait_name; i++) + for (unsigned int i = 0; NULL != traits[i].trait_name; i++) { if ( (0 == strcmp (trait, traits[i].trait_name)) && (index == traits[i].index) ) diff --git a/src/lib/testing_auditor_api_cmd_deposit_confirmation.c b/src/lib/testing_auditor_api_cmd_deposit_confirmation.c index f52352669..3ea6390d8 100644 --- a/src/lib/testing_auditor_api_cmd_deposit_confirmation.c +++ b/src/lib/testing_auditor_api_cmd_deposit_confirmation.c @@ -117,8 +117,8 @@ do_retry (void *cls) dcs->retry_task = NULL; deposit_confirmation_run (dcs, - NULL, - dcs->is); + NULL, + dcs->is); } @@ -141,12 +141,12 @@ deposit_confirmation_cb (void *cls, dcs->dc = NULL; if (dcs->expected_response_code != http_status) - { + { if (GNUNET_YES == dcs->do_retry) { if ( (0 == http_status) || (TALER_EC_DB_COMMIT_FAILED_ON_RETRY == ec) || - (MHD_HTTP_INTERNAL_SERVER_ERROR == http_status) ) + (MHD_HTTP_INTERNAL_SERVER_ERROR == http_status) ) { GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Retrying deposit confirmation failed with %u/%d\n", @@ -220,22 +220,22 @@ deposit_confirmation_run (void *cls, } GNUNET_assert (GNUNET_OK == - TALER_TESTING_get_trait_exchange_pub (deposit_cmd, - dcs->coin_index, - &exchange_pub)); + TALER_TESTING_get_trait_exchange_pub (deposit_cmd, + dcs->coin_index, + &exchange_pub)); GNUNET_assert (GNUNET_OK == - TALER_TESTING_get_trait_exchange_sig (deposit_cmd, - dcs->coin_index, - &exchange_sig)); + TALER_TESTING_get_trait_exchange_sig (deposit_cmd, + dcs->coin_index, + &exchange_sig)); keys = TALER_EXCHANGE_get_keys (dcs->is->exchange); GNUNET_assert (NULL != keys); spk = TALER_EXCHANGE_get_exchange_signing_key_info (keys, exchange_pub); GNUNET_assert (GNUNET_OK == - TALER_TESTING_get_trait_contract_terms (deposit_cmd, - dcs->coin_index, - &contract_terms)); + TALER_TESTING_get_trait_contract_terms (deposit_cmd, + dcs->coin_index, + &contract_terms)); /* Very unlikely to fail */ GNUNET_assert (NULL != contract_terms); GNUNET_assert (GNUNET_OK == @@ -267,7 +267,7 @@ deposit_confirmation_run (void *cls, { struct GNUNET_JSON_Specification spec[] = { GNUNET_JSON_spec_absolute_time ("timestamp", ×tamp), - GNUNET_JSON_spec_end() + GNUNET_JSON_spec_end () }; if (GNUNET_OK != @@ -284,7 +284,7 @@ deposit_confirmation_run (void *cls, { struct GNUNET_JSON_Specification spec[] = { GNUNET_JSON_spec_absolute_time ("refund_deadline", &refund_deadline), - GNUNET_JSON_spec_end() + GNUNET_JSON_spec_end () }; if (GNUNET_OK != @@ -296,23 +296,23 @@ deposit_confirmation_run (void *cls, } } dcs->dc = TALER_AUDITOR_deposit_confirmation - (dcs->auditor, - &h_wire, - &h_contract_terms, - timestamp, - refund_deadline, - &amount_without_fee, - &coin_pub, - &merchant_pub, - exchange_pub, - exchange_sig, - &keys->master_pub, - spk->valid_from, - spk->valid_until, - spk->valid_legal, - &spk->master_sig, - &deposit_confirmation_cb, - dcs); + (dcs->auditor, + &h_wire, + &h_contract_terms, + timestamp, + refund_deadline, + &amount_without_fee, + &coin_pub, + &merchant_pub, + exchange_pub, + exchange_sig, + &keys->master_pub, + spk->valid_from, + spk->valid_until, + spk->valid_legal, + &spk->master_sig, + &deposit_confirmation_cb, + dcs); if (NULL == dcs->dc) { @@ -395,11 +395,11 @@ deposit_confirmation_traits (void *cls, struct TALER_TESTING_Command TALER_TESTING_cmd_deposit_confirmation (const char *label, - struct TALER_AUDITOR_Handle *auditor, - const char *deposit_reference, - unsigned int coin_index, - const char *amount_without_fee, - unsigned int expected_response_code) + struct TALER_AUDITOR_Handle *auditor, + const char *deposit_reference, + unsigned int coin_index, + const char *amount_without_fee, + unsigned int expected_response_code) { struct TALER_TESTING_Command cmd = {0}; /* need explicit zeroing..*/ struct DepositConfirmationState *dcs; @@ -429,7 +429,8 @@ TALER_TESTING_cmd_deposit_confirmation * @return the command with retries enabled */ struct TALER_TESTING_Command -TALER_TESTING_cmd_deposit_confirmation_with_retry (struct TALER_TESTING_Command cmd) +TALER_TESTING_cmd_deposit_confirmation_with_retry (struct TALER_TESTING_Command + cmd) { struct DepositConfirmationState *dcs; diff --git a/src/lib/testing_auditor_api_cmd_exchanges.c b/src/lib/testing_auditor_api_cmd_exchanges.c index 2f002627e..014441761 100644 --- a/src/lib/testing_auditor_api_cmd_exchanges.c +++ b/src/lib/testing_auditor_api_cmd_exchanges.c @@ -88,8 +88,8 @@ struct ExchangesState */ static void exchanges_run (void *cls, - const struct TALER_TESTING_Command *cmd, - struct TALER_TESTING_Interpreter *is); + const struct TALER_TESTING_Command *cmd, + struct TALER_TESTING_Interpreter *is); /** @@ -104,8 +104,8 @@ do_retry (void *cls) es->retry_task = NULL; exchanges_run (es, - NULL, - es->is); + NULL, + es->is); } @@ -119,11 +119,11 @@ do_retry (void *cls) */ static void exchanges_cb (void *cls, - unsigned int http_status, - enum TALER_ErrorCode ec, - unsigned int num_exchanges, - const struct TALER_AUDITOR_ExchangeInfo *ei, - const json_t *raw_response) + unsigned int http_status, + enum TALER_ErrorCode ec, + unsigned int num_exchanges, + const struct TALER_AUDITOR_ExchangeInfo *ei, + const json_t *raw_response) { struct ExchangesState *es = cls; @@ -134,30 +134,30 @@ exchanges_cb (void *cls, { if ( (0 == http_status) || (TALER_EC_DB_COMMIT_FAILED_ON_RETRY == ec) || - (MHD_HTTP_INTERNAL_SERVER_ERROR == http_status) ) + (MHD_HTTP_INTERNAL_SERVER_ERROR == http_status) ) { GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Retrying list exchanges failed with %u/%d\n", http_status, (int) ec); - /* on DB conflicts, do not use backoff */ - if (TALER_EC_DB_COMMIT_FAILED_ON_RETRY == ec) - es->backoff = GNUNET_TIME_UNIT_ZERO; - else - es->backoff = EXCHANGE_LIB_BACKOFF (es->backoff); - es->retry_task = GNUNET_SCHEDULER_add_delayed (es->backoff, - &do_retry, - es); + /* on DB conflicts, do not use backoff */ + if (TALER_EC_DB_COMMIT_FAILED_ON_RETRY == ec) + es->backoff = GNUNET_TIME_UNIT_ZERO; + else + es->backoff = EXCHANGE_LIB_BACKOFF (es->backoff); + es->retry_task = GNUNET_SCHEDULER_add_delayed (es->backoff, + &do_retry, + es); return; } } GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Unexpected response code %u to command %s in %s:%u\n", - http_status, - es->is->commands[es->is->ip].label, - __FILE__, - __LINE__); + "Unexpected response code %u to command %s in %s:%u\n", + http_status, + es->is->commands[es->is->ip].label, + __FILE__, + __LINE__); json_dumpf (raw_response, stderr, 0); TALER_TESTING_interpreter_fail (es->is); return; @@ -166,7 +166,7 @@ exchanges_cb (void *cls, { unsigned int found = GNUNET_NO; - for (unsigned int i=0; + for (unsigned int i = 0; iexchange_url, @@ -176,7 +176,7 @@ exchanges_cb (void *cls, { TALER_LOG_ERROR ("Exchange '%s' doesn't exist at this auditor\n", - es->exchange_url); + es->exchange_url); TALER_TESTING_interpreter_fail (es->is); return; } @@ -197,16 +197,16 @@ exchanges_cb (void *cls, */ static void exchanges_run (void *cls, - const struct TALER_TESTING_Command *cmd, - struct TALER_TESTING_Interpreter *is) + const struct TALER_TESTING_Command *cmd, + struct TALER_TESTING_Interpreter *is) { struct ExchangesState *es = cls; es->is = is; es->leh = TALER_AUDITOR_list_exchanges - (is->auditor, - &exchanges_cb, - es); + (is->auditor, + &exchanges_cb, + es); if (NULL == es->leh) { @@ -227,7 +227,7 @@ exchanges_run (void *cls, */ static void exchanges_cleanup (void *cls, - const struct TALER_TESTING_Command *cmd) + const struct TALER_TESTING_Command *cmd) { struct ExchangesState *es = cls; @@ -261,9 +261,9 @@ exchanges_cleanup (void *cls, */ static int exchanges_traits (void *cls, - const void **ret, - const char *trait, - unsigned int index) + const void **ret, + const char *trait, + unsigned int index) { /* Must define this function because some callbacks * look for certain traits on _all_ the commands. */ @@ -282,8 +282,8 @@ exchanges_traits (void *cls, struct TALER_TESTING_Command TALER_TESTING_cmd_exchanges (const char *label, - struct TALER_AUDITOR_Handle *auditor, - unsigned int expected_response_code) + struct TALER_AUDITOR_Handle *auditor, + unsigned int expected_response_code) { struct TALER_TESTING_Command cmd = {0}; /* need explicit zeroing..*/ struct ExchangesState *es; @@ -316,8 +316,8 @@ TALER_TESTING_cmd_exchanges struct TALER_TESTING_Command TALER_TESTING_cmd_exchanges_with_url (const char *label, - unsigned int expected_response_code, - const char *exchange_url) + unsigned int expected_response_code, + const char *exchange_url) { struct TALER_TESTING_Command cmd = {0}; /* need explicit zeroing..*/ struct ExchangesState *es; diff --git a/src/lib/testing_auditor_api_helpers.c b/src/lib/testing_auditor_api_helpers.c index 4bbfc51d1..59b0e05de 100644 --- a/src/lib/testing_auditor_api_helpers.c +++ b/src/lib/testing_auditor_api_helpers.c @@ -108,8 +108,8 @@ struct MainWrapperContext static void auditor_version_cb (void *cls, - const struct TALER_AUDITOR_VersionInformation *vi, - enum TALER_AUDITOR_VersionCompatibility compat) + const struct TALER_AUDITOR_VersionInformation *vi, + enum TALER_AUDITOR_VersionCompatibility compat) { struct TALER_TESTING_Interpreter *is = cls; @@ -141,7 +141,7 @@ auditor_main_wrapper (void *cls, "auditor", "BASE_URL", &auditor_base_url)) - { + { GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, "auditor", "BASE_URL"); diff --git a/src/pq/pq_query_helper.c b/src/pq/pq_query_helper.c index 1a03c2d49..31336b796 100644 --- a/src/pq/pq_query_helper.c +++ b/src/pq/pq_query_helper.c @@ -79,7 +79,7 @@ struct GNUNET_PQ_QueryParam TALER_PQ_query_param_amount_nbo (const struct TALER_AmountNBO *x) { struct GNUNET_PQ_QueryParam res = - { &qconv_amount_nbo, NULL, x, sizeof (*x), 2 }; + { &qconv_amount_nbo, NULL, x, sizeof (*x), 2 }; return res; } @@ -142,7 +142,7 @@ struct GNUNET_PQ_QueryParam TALER_PQ_query_param_amount (const struct TALER_Amount *x) { struct GNUNET_PQ_QueryParam res = - { &qconv_amount, NULL, x, sizeof (*x), 2 }; + { &qconv_amount, NULL, x, sizeof (*x), 2 }; return res; } @@ -196,7 +196,7 @@ struct GNUNET_PQ_QueryParam TALER_PQ_query_param_json (const json_t *x) { struct GNUNET_PQ_QueryParam res = - { &qconv_json, NULL, x, 0, 1 }; + { &qconv_json, NULL, x, 0, 1 }; return res; } @@ -260,7 +260,7 @@ struct GNUNET_PQ_QueryParam TALER_PQ_query_param_absolute_time (const struct GNUNET_TIME_Absolute *x) { struct GNUNET_PQ_QueryParam res = - { &qconv_round_time, NULL, x, sizeof (*x), 1 }; + { &qconv_round_time, NULL, x, sizeof (*x), 1 }; return res; } @@ -316,10 +316,10 @@ qconv_round_time_abs (void *cls, * @param x pointer to the query parameter to pass */ struct GNUNET_PQ_QueryParam -TALER_PQ_query_param_absolute_time_nbo(const struct GNUNET_TIME_AbsoluteNBO *x) +TALER_PQ_query_param_absolute_time_nbo (const struct GNUNET_TIME_AbsoluteNBO *x) { struct GNUNET_PQ_QueryParam res = - { &qconv_round_time_abs, NULL, x, sizeof (*x), 1 }; + { &qconv_round_time_abs, NULL, x, sizeof (*x), 1 }; return res; } diff --git a/src/pq/pq_result_helper.c b/src/pq/pq_result_helper.c index 92b8e8f4f..97710c43e 100644 --- a/src/pq/pq_result_helper.c +++ b/src/pq/pq_result_helper.c @@ -171,7 +171,7 @@ TALER_PQ_result_spec_amount_nbo (const char *name, .dst_size = sizeof (*amount), .fname = name }; - + return res; } @@ -245,7 +245,7 @@ TALER_PQ_result_spec_amount (const char *name, .dst_size = sizeof (*amount), .fname = name }; - + return res; } @@ -352,7 +352,7 @@ TALER_PQ_result_spec_json (const char *name, .dst = (void *) jp, .fname = name }; - + return res; } @@ -391,8 +391,8 @@ extract_round_time (void *cls, return GNUNET_SYSERR; } if (PQgetisnull (result, - row, - fnum)) + row, + fnum)) { GNUNET_break (0); return GNUNET_SYSERR; @@ -511,7 +511,7 @@ TALER_PQ_result_spec_absolute_time_nbo (const char *name, struct GNUNET_TIME_AbsoluteNBO *at) { struct GNUNET_PQ_ResultSpec res = { - .conv = &extract_round_time_nbo, + .conv = &extract_round_time_nbo, .dst = (void *) at, .dst_size = sizeof (struct GNUNET_TIME_AbsoluteNBO), .fname = name diff --git a/src/pq/test_pq.c b/src/pq/test_pq.c index 471326f02..e9d0f3e16 100644 --- a/src/pq/test_pq.c +++ b/src/pq/test_pq.c @@ -91,7 +91,7 @@ run_queries (PGconn *conn) TALER_string_to_amount ("EUR:5.5", &hamount)); TALER_amount_hton (&namount, - &hamount); + &hamount); GNUNET_assert (GNUNET_OK == TALER_string_to_amount ("EUR:4.4", &hamount)); @@ -113,8 +113,8 @@ run_queries (PGconn *conn) if (PGRES_COMMAND_OK != PQresultStatus (result)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Database failure: %s\n", - PQresultErrorMessage (result)); + "Database failure: %s\n", + PQresultErrorMessage (result)); PQclear (result); return 1; } @@ -146,19 +146,19 @@ run_queries (PGconn *conn) }; ret = GNUNET_PQ_extract_result (result, - results_select, - 0); + results_select, + 0); GNUNET_break (0 == - TALER_amount_cmp (&hamount, - &hamount2)); + TALER_amount_cmp (&hamount, + &hamount2)); GNUNET_assert (GNUNET_OK == TALER_string_to_amount ("EUR:5.5", &hamount)); TALER_amount_ntoh (&hamount2, - &namount2); + &namount2); GNUNET_break (0 == - TALER_amount_cmp (&hamount, - &hamount2)); + TALER_amount_cmp (&hamount, + &hamount2)); GNUNET_break (42 == json_integer_value (json_object_get (json2, "foo"))); GNUNET_PQ_cleanup_result (results_select); @@ -173,8 +173,8 @@ run_queries (PGconn *conn) int -main(int argc, - const char *const argv[]) +main (int argc, + const char *const argv[]) { PGconn *conn; PGresult *result; @@ -187,21 +187,21 @@ main(int argc, if (CONNECTION_OK != PQstatus (conn)) { fprintf (stderr, - "Cannot run test, database connection failed: %s\n", - PQerrorMessage (conn)); + "Cannot run test, database connection failed: %s\n", + PQerrorMessage (conn)); GNUNET_break (0); PQfinish (conn); return 0; /* We ignore this type of error... */ } result = PQexec (conn, - "CREATE TEMPORARY TABLE IF NOT EXISTS test_pq (" - " hamount_val INT8 NOT NULL" - ",hamount_frac INT4 NOT NULL" - ",namount_val INT8 NOT NULL" - ",namount_frac INT4 NOT NULL" - ",json VARCHAR NOT NULL" - ")"); + "CREATE TEMPORARY TABLE IF NOT EXISTS test_pq (" + " hamount_val INT8 NOT NULL" + ",hamount_frac INT4 NOT NULL" + ",namount_val INT8 NOT NULL" + ",namount_frac INT4 NOT NULL" + ",json VARCHAR NOT NULL" + ")"); if (PGRES_COMMAND_OK != PQresultStatus (result)) { fprintf (stderr, diff --git a/src/util/amount.c b/src/util/amount.c index ac6be27d8..8e801267f 100644 --- a/src/util/amount.c +++ b/src/util/amount.c @@ -69,7 +69,7 @@ TALER_string_to_amount (const char *str, invalidate (denom); /* skip leading whitespace */ - while (isspace( (unsigned char) str[0])) + while (isspace ( (unsigned char) str[0])) str++; if ('\0' == str[0]) { @@ -164,7 +164,7 @@ TALER_string_to_amount (const char *str, } return GNUNET_OK; - fail: + fail: /* set currency to 'invalid' to prevent accidental use */ memset (denom->currency, 0, @@ -208,7 +208,7 @@ TALER_amount_hton (struct TALER_AmountNBO *res, const struct TALER_Amount *d) { GNUNET_assert (GNUNET_YES == - TALER_amount_is_valid (d)); + TALER_amount_is_valid (d)); res->value = GNUNET_htonll (d->value); res->fraction = htonl (d->fraction); memcpy (res->currency, @@ -233,7 +233,7 @@ TALER_amount_ntoh (struct TALER_Amount *res, dn->currency, TALER_CURRENCY_LEN); GNUNET_assert (GNUNET_YES == - TALER_amount_is_valid (res)); + TALER_amount_is_valid (res)); } @@ -308,7 +308,7 @@ TALER_amount_cmp_currency (const struct TALER_Amount *a1, (GNUNET_NO == TALER_amount_is_valid (a2)) ) return GNUNET_SYSERR; if (0 == strcasecmp (a1->currency, - a2->currency)) + a2->currency)) return GNUNET_YES; return GNUNET_NO; } @@ -331,7 +331,7 @@ TALER_amount_cmp_currency_nbo (const struct TALER_AmountNBO *a1, (GNUNET_NO == test_valid_nbo (a2)) ) return GNUNET_SYSERR; if (0 == strcasecmp (a1->currency, - a2->currency)) + a2->currency)) return GNUNET_YES; return GNUNET_NO; } @@ -362,9 +362,9 @@ TALER_amount_cmp (const struct TALER_Amount *a1, n1 = *a1; n2 = *a2; GNUNET_assert (GNUNET_SYSERR != - TALER_amount_normalize (&n1)); + TALER_amount_normalize (&n1)); GNUNET_assert (GNUNET_SYSERR != - TALER_amount_normalize (&n2)); + TALER_amount_normalize (&n2)); if (n1.value == n2.value) { if (n1.fraction < n2.fraction) diff --git a/src/util/crypto.c b/src/util/crypto.c index 95eb11eba..4ddd86c1a 100644 --- a/src/util/crypto.c +++ b/src/util/crypto.c @@ -48,14 +48,14 @@ fatal_error_handler (void *cls, fprintf (stderr, "Fatal error in libgcrypt: %s\n", msg); - abort(); + abort (); } /** * Initialize libgcrypt. */ -void __attribute__ ((constructor)) +void __attribute__ ((constructor)) TALER_gcrypt_init () { gcry_set_fatalerror_handler (&fatal_error_handler, @@ -125,8 +125,10 @@ TALER_test_coin_valid (const struct TALER_CoinPublicInfo *coin_public_info, * @param[out] ts computed transfer secret */ void -TALER_link_derive_transfer_secret (const struct TALER_CoinSpendPrivateKeyP *coin_priv, - const struct TALER_TransferPrivateKeyP *trans_priv, +TALER_link_derive_transfer_secret (const struct + TALER_CoinSpendPrivateKeyP *coin_priv, + const struct + TALER_TransferPrivateKeyP *trans_priv, struct TALER_TransferSecretP *ts) { struct TALER_CoinSpendPublicKeyP coin_pub; @@ -150,8 +152,10 @@ TALER_link_derive_transfer_secret (const struct TALER_CoinSpendPrivateKeyP *coin * @param[out] transfer_secret set to the shared secret */ void -TALER_link_reveal_transfer_secret (const struct TALER_TransferPrivateKeyP *trans_priv, - const struct TALER_CoinSpendPublicKeyP *coin_pub, +TALER_link_reveal_transfer_secret (const struct + TALER_TransferPrivateKeyP *trans_priv, + const struct + TALER_CoinSpendPublicKeyP *coin_pub, struct TALER_TransferSecretP *transfer_secret) { GNUNET_assert (GNUNET_OK == @@ -170,9 +174,12 @@ TALER_link_reveal_transfer_secret (const struct TALER_TransferPrivateKeyP *trans * @param[out] transfer_secret set to the shared secret */ void -TALER_link_recover_transfer_secret (const struct TALER_TransferPublicKeyP *trans_pub, - const struct TALER_CoinSpendPrivateKeyP *coin_priv, - struct TALER_TransferSecretP *transfer_secret) +TALER_link_recover_transfer_secret (const struct + TALER_TransferPublicKeyP *trans_pub, + const struct + TALER_CoinSpendPrivateKeyP *coin_priv, + struct TALER_TransferSecretP * + transfer_secret) { GNUNET_assert (GNUNET_OK == GNUNET_CRYPTO_eddsa_ecdh (&coin_priv->eddsa_priv, @@ -349,7 +356,7 @@ TALER_refresh_get_commitment (struct TALER_RefreshCommitmentP *rc, hash_context = GNUNET_CRYPTO_hash_context_start (); /* first, iterate over transfer public keys for hash_context */ - for (unsigned int i=0;i 0); /* sanity check */ - buf_size = GNUNET_CRYPTO_rsa_public_key_encode (rcs[0].new_coins[i].dk->rsa_public_key, - &buf); + buf_size = GNUNET_CRYPTO_rsa_public_key_encode ( + rcs[0].new_coins[i].dk->rsa_public_key, + &buf); GNUNET_CRYPTO_hash_context_read (hash_context, - buf, - buf_size); + buf, + buf_size); GNUNET_free (buf); } @@ -388,11 +396,11 @@ TALER_refresh_get_commitment (struct TALER_RefreshCommitmentP *rc, } /* finally, add all the envelopes */ - for (unsigned int i=0;inew_coins[j]; diff --git a/src/util/crypto_wire.c b/src/util/crypto_wire.c index ca6b9d216..e799812e4 100644 --- a/src/util/crypto_wire.c +++ b/src/util/crypto_wire.c @@ -55,8 +55,10 @@ TALER_exchange_wire_signature_hash (const char *payto_url, */ int TALER_exchange_wire_signature_check (const char *payto_url, - const struct TALER_MasterPublicKeyP *master_pub, - const struct TALER_MasterSignatureP *master_sig) + const struct + TALER_MasterPublicKeyP *master_pub, + const struct + TALER_MasterSignatureP *master_sig) { struct TALER_MasterWireDetailsPS wd; @@ -80,7 +82,8 @@ TALER_exchange_wire_signature_check (const char *payto_url, */ void TALER_exchange_wire_signature_make (const char *payto_url, - const struct TALER_MasterPrivateKeyP *master_priv, + const struct + TALER_MasterPrivateKeyP *master_priv, struct TALER_MasterSignatureP *master_sig) { struct TALER_MasterWireDetailsPS wd; @@ -134,8 +137,10 @@ TALER_merchant_wire_signature_hash (const char *payto_url, int TALER_merchant_wire_signature_check (const char *payto_url, const char *salt, - const struct TALER_MerchantPublicKeyP *merch_pub, - const struct TALER_MerchantSignatureP *merch_sig) + const struct + TALER_MerchantPublicKeyP *merch_pub, + const struct + TALER_MerchantSignatureP *merch_sig) { struct TALER_MasterWireDetailsPS wd; @@ -162,7 +167,8 @@ TALER_merchant_wire_signature_check (const char *payto_url, void TALER_merchant_wire_signature_make (const char *payto_url, const char *salt, - const struct TALER_MerchantPrivateKeyP *merch_priv, + const struct + TALER_MerchantPrivateKeyP *merch_priv, struct TALER_MerchantSignatureP *merch_sig) { struct TALER_MasterWireDetailsPS wd; diff --git a/src/util/test_amount.c b/src/util/test_amount.c index 3854297dd..a8b37823c 100644 --- a/src/util/test_amount.c +++ b/src/util/test_amount.c @@ -25,8 +25,8 @@ int -main(int argc, - const char *const argv[]) +main (int argc, + const char *const argv[]) { struct TALER_Amount a1; struct TALER_Amount a2; @@ -34,51 +34,52 @@ main(int argc, char *c; GNUNET_log_setup ("test-amout", - "WARNING", - NULL); + "WARNING", + NULL); /* test invalid conversions */ GNUNET_log_skip (6, GNUNET_NO); /* non-numeric */ GNUNET_assert (GNUNET_SYSERR == - TALER_string_to_amount ("EUR:4a", - &a1)); + TALER_string_to_amount ("EUR:4a", + &a1)); /* non-numeric */ GNUNET_assert (GNUNET_SYSERR == - TALER_string_to_amount ("EUR:4.4a", - &a1)); + TALER_string_to_amount ("EUR:4.4a", + &a1)); /* non-numeric */ GNUNET_assert (GNUNET_SYSERR == - TALER_string_to_amount ("EUR:4.a4", - &a1)); + TALER_string_to_amount ("EUR:4.a4", + &a1)); /* no currency */ GNUNET_assert (GNUNET_SYSERR == - TALER_string_to_amount (":4.a4", - &a1)); + TALER_string_to_amount (":4.a4", + &a1)); /* precision too high */ GNUNET_assert (GNUNET_SYSERR == - TALER_string_to_amount ("EUR:4.123456789", - &a1)); + TALER_string_to_amount ("EUR:4.123456789", + &a1)); /* value too big */ GNUNET_assert (GNUNET_SYSERR == - TALER_string_to_amount ("EUR:1234567890123456789012345678901234567890123456789012345678901234567890", - &a1)); + TALER_string_to_amount ( + "EUR:1234567890123456789012345678901234567890123456789012345678901234567890", + &a1)); GNUNET_log_skip (0, GNUNET_YES); /* test conversion without fraction */ GNUNET_assert (GNUNET_OK == - TALER_string_to_amount ("EUR:4", - &a1)); + TALER_string_to_amount ("EUR:4", + &a1)); GNUNET_assert (0 == strcasecmp ("EUR", - a1.currency)); + a1.currency)); GNUNET_assert (4 == a1.value); GNUNET_assert (0 == a1.fraction); /* test conversion with leading zero in fraction */ GNUNET_assert (GNUNET_OK == - TALER_string_to_amount ("eur:0.02", - &a2)); + TALER_string_to_amount ("eur:0.02", + &a2)); GNUNET_assert (0 == strcasecmp ("eur", - a2.currency)); + a2.currency)); GNUNET_assert (0 == a2.value); GNUNET_assert (TALER_AMOUNT_FRAC_BASE / 100 * 2 == a2.fraction); c = TALER_amount_to_string (&a2); @@ -88,95 +89,95 @@ main(int argc, /* test conversion with leading space and with fraction */ GNUNET_assert (GNUNET_OK == - TALER_string_to_amount (" eur:4.12", - &a2)); + TALER_string_to_amount (" eur:4.12", + &a2)); GNUNET_assert (0 == strcasecmp ("eur", - a2.currency)); + a2.currency)); GNUNET_assert (4 == a2.value); GNUNET_assert (TALER_AMOUNT_FRAC_BASE / 100 * 12 == a2.fraction); /* test use of local currency */ GNUNET_assert (GNUNET_OK == - TALER_string_to_amount (" *LOCAL:4444.1000", - &a3)); + TALER_string_to_amount (" *LOCAL:4444.1000", + &a3)); GNUNET_assert (0 == strcasecmp ("*LOCAL", - a3.currency)); + a3.currency)); GNUNET_assert (4444 == a3.value); GNUNET_assert (TALER_AMOUNT_FRAC_BASE / 10 == a3.fraction); /* test CMP with equal and unequal currencies */ GNUNET_assert (GNUNET_NO == - TALER_amount_cmp_currency (&a1, - &a3)); + TALER_amount_cmp_currency (&a1, + &a3)); GNUNET_assert (GNUNET_YES == - TALER_amount_cmp_currency (&a1, - &a2)); + TALER_amount_cmp_currency (&a1, + &a2)); /* test subtraction failure (currency missmatch) */ GNUNET_assert (GNUNET_SYSERR == - TALER_amount_subtract (&a3, - &a3, - &a2)); + TALER_amount_subtract (&a3, + &a3, + &a2)); GNUNET_assert (GNUNET_SYSERR == - TALER_amount_normalize (&a3)); + TALER_amount_normalize (&a3)); /* test subtraction failure (negative result) */ GNUNET_assert (GNUNET_SYSERR == - TALER_amount_subtract (&a3, - &a1, - &a2)); + TALER_amount_subtract (&a3, + &a1, + &a2)); GNUNET_assert (GNUNET_SYSERR == - TALER_amount_normalize (&a3)); + TALER_amount_normalize (&a3)); /* test subtraction success cases */ GNUNET_assert (GNUNET_YES == - TALER_amount_subtract (&a3, - &a2, - &a1)); + TALER_amount_subtract (&a3, + &a2, + &a1)); GNUNET_assert (GNUNET_NO == - TALER_amount_subtract (&a3, - &a1, - &a1)); + TALER_amount_subtract (&a3, + &a1, + &a1)); GNUNET_assert (0 == a3.value); GNUNET_assert (0 == a3.fraction); GNUNET_assert (GNUNET_NO == - TALER_amount_normalize (&a3)); + TALER_amount_normalize (&a3)); /* test addition success */ GNUNET_assert (GNUNET_OK == - TALER_amount_add (&a3, - &a3, - &a2)); + TALER_amount_add (&a3, + &a3, + &a2)); GNUNET_assert (GNUNET_NO == - TALER_amount_normalize (&a3)); + TALER_amount_normalize (&a3)); /* test normalization */ a3.fraction = 2 * TALER_AMOUNT_FRAC_BASE; a3.value = 4; GNUNET_assert (GNUNET_YES == - TALER_amount_normalize (&a3)); + TALER_amount_normalize (&a3)); /* test conversion to string */ c = TALER_amount_to_string (&a3); GNUNET_assert (0 == strcmp ("EUR:6", - c)); + c)); GNUNET_free (c); /* test normalization with fraction overflow */ a3.fraction = 2 * TALER_AMOUNT_FRAC_BASE + 1; a3.value = 4; GNUNET_assert (GNUNET_YES == - TALER_amount_normalize (&a3)); + TALER_amount_normalize (&a3)); c = TALER_amount_to_string (&a3); GNUNET_assert (0 == strcmp ("EUR:6.00000001", - c)); + c)); GNUNET_free (c); /* test normalization with overflow */ a3.fraction = 2 * TALER_AMOUNT_FRAC_BASE + 1; a3.value = UINT64_MAX - 1; GNUNET_assert (GNUNET_SYSERR == - TALER_amount_normalize (&a3)); + TALER_amount_normalize (&a3)); c = TALER_amount_to_string (&a3); GNUNET_assert (NULL == c); @@ -186,7 +187,7 @@ main(int argc, a2.fraction = 2; a2.value = 5; GNUNET_assert (GNUNET_SYSERR == - TALER_amount_add (&a3, &a1, &a2)); + TALER_amount_add (&a3, &a1, &a2)); /* test addition with underflow on fraction */ a1.fraction = 1; @@ -194,19 +195,19 @@ main(int argc, a2.fraction = 2; a2.value = 0; GNUNET_assert (GNUNET_OK == - TALER_amount_subtract (&a3, &a1, &a2)); + TALER_amount_subtract (&a3, &a1, &a2)); GNUNET_assert (UINT64_MAX - 1 == a3.value); GNUNET_assert (TALER_AMOUNT_FRAC_BASE - 1 == a3.fraction); /* test division */ GNUNET_assert (GNUNET_OK == - TALER_string_to_amount ("EUR:3.33", - &a1)); + TALER_string_to_amount ("EUR:3.33", + &a1)); TALER_amount_divide (&a2, &a1, 1); GNUNET_assert (0 == strcasecmp ("EUR", - a2.currency)); + a2.currency)); GNUNET_assert (3 == a2.value); GNUNET_assert (TALER_AMOUNT_FRAC_BASE / 100 * 33 == a2.fraction); @@ -214,7 +215,7 @@ main(int argc, &a1, 3); GNUNET_assert (0 == strcasecmp ("EUR", - a2.currency)); + a2.currency)); GNUNET_assert (1 == a2.value); GNUNET_assert (TALER_AMOUNT_FRAC_BASE / 100 * 11 == a2.fraction); @@ -222,14 +223,14 @@ main(int argc, &a1, 2); GNUNET_assert (0 == strcasecmp ("EUR", - a2.currency)); + a2.currency)); GNUNET_assert (1 == a2.value); GNUNET_assert (TALER_AMOUNT_FRAC_BASE / 1000 * 665 == a2.fraction); TALER_amount_divide (&a2, &a1, TALER_AMOUNT_FRAC_BASE * 2); GNUNET_assert (0 == strcasecmp ("EUR", - a2.currency)); + a2.currency)); GNUNET_assert (0 == a2.value); GNUNET_assert (1 == a2.fraction); diff --git a/src/util/test_crypto.c b/src/util/test_crypto.c index bba9275af..c3c7b957c 100644 --- a/src/util/test_crypto.c +++ b/src/util/test_crypto.c @@ -47,12 +47,12 @@ test_high_level () coin_priv.eddsa_priv = *pk; GNUNET_free (pk); GNUNET_CRYPTO_eddsa_key_get_public (&coin_priv.eddsa_priv, - &coin_pub.eddsa_pub); + &coin_pub.eddsa_pub); pk2 = GNUNET_CRYPTO_ecdhe_key_create (); trans_priv.ecdhe_priv = *pk2; GNUNET_free (pk2); GNUNET_CRYPTO_ecdhe_key_get_public (&trans_priv.ecdhe_priv, - &trans_pub.ecdhe_pub); + &trans_pub.ecdhe_pub); TALER_link_derive_transfer_secret (&coin_priv, &trans_priv, &secret); @@ -98,7 +98,8 @@ test_planchets () struct TALER_FreshCoin coin; dk_priv.rsa_private_key = GNUNET_CRYPTO_rsa_private_key_create (1024); - dk_pub.rsa_public_key = GNUNET_CRYPTO_rsa_private_key_get_public (dk_priv.rsa_private_key); + dk_pub.rsa_public_key = GNUNET_CRYPTO_rsa_private_key_get_public ( + dk_priv.rsa_private_key); TALER_planchet_setup_random (&ps); GNUNET_assert (GNUNET_OK == TALER_planchet_prepare (&dk_pub, @@ -123,8 +124,8 @@ test_planchets () int -main(int argc, - const char *const argv[]) +main (int argc, + const char *const argv[]) { if (0 != test_high_level ()) return 1; diff --git a/src/util/test_url.c b/src/util/test_url.c index 3734da4e0..59a5e3fa7 100644 --- a/src/util/test_url.c +++ b/src/util/test_url.c @@ -49,10 +49,14 @@ main (int argc, cf (TALER_urlencode ("foo bar "), "foo%20bar%20"); cf (TALER_urlencode ("% % "), "%25%20%25%20"); - cf (TALER_url_join ("https://taler.net/", "foo", NULL), "https://taler.net/foo"); - cf (TALER_url_join ("https://taler.net", "foo", NULL), "https://taler.net/foo"); - cf (TALER_url_join ("https://taler.net/", "/foo", NULL), "https://taler.net/foo"); - cf (TALER_url_join ("https://taler.net/", "/foo/", NULL), "https://taler.net/foo/"); + cf (TALER_url_join ("https://taler.net/", "foo", NULL), + "https://taler.net/foo"); + cf (TALER_url_join ("https://taler.net", "foo", NULL), + "https://taler.net/foo"); + cf (TALER_url_join ("https://taler.net/", "/foo", NULL), + "https://taler.net/foo"); + cf (TALER_url_join ("https://taler.net/", "/foo/", NULL), + "https://taler.net/foo/"); cf (TALER_url_join ("https://taler.net/", "foo", "x", "42", NULL), "https://taler.net/foo?x=42"); diff --git a/src/util/util.c b/src/util/util.c index eea4c91aa..e4697fab4 100644 --- a/src/util/util.c +++ b/src/util/util.c @@ -46,13 +46,13 @@ TALER_b2s (const void *buf, char *tmp; GNUNET_CRYPTO_hash (buf, - buf_size, - &hc); + buf_size, + &hc); tmp = GNUNET_STRINGS_data_to_string_alloc (&hc, sizeof (hc)); memcpy (ret, - tmp, - 8); + tmp, + 8); GNUNET_free (tmp); ret[8] = '\0'; return ret; @@ -120,7 +120,7 @@ set_amount (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, amount)) { FPRINTF (stderr, - _("Failed to parse amount in option `%s'\n"), + _ ("Failed to parse amount in option `%s'\n"), option); return GNUNET_SYSERR; } @@ -168,25 +168,26 @@ TALER_getopt_get_amount (char shortName, * #GNUNET_NO otherwise */ static bool -is_reserved(char c) +is_reserved (char c) { - switch (c) { - case '0': case '1': case '2': case '3': case '4': - case '5': case '6': case '7': case '8': case '9': - case 'a': case 'b': case 'c': case 'd': case 'e': - case 'f': case 'g': case 'h': case 'i': case 'j': - case 'k': case 'l': case 'm': case 'n': case 'o': - case 'p': case 'q': case 'r': case 's': case 't': - case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': - case 'A': case 'B': case 'C': case 'D': case 'E': - case 'F': case 'G': case 'H': case 'I': case 'J': - case 'K': case 'L': case 'M': case 'N': case 'O': - case 'P': case 'Q': case 'R': case 'S': case 'T': - case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': - case '-': case '.': case '_': case '~': - return GNUNET_NO; - default: - break; + switch (c) + { + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + case 'a': case 'b': case 'c': case 'd': case 'e': + case 'f': case 'g': case 'h': case 'i': case 'j': + case 'k': case 'l': case 'm': case 'n': case 'o': + case 'p': case 'q': case 'r': case 's': case 't': + case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': + case 'A': case 'B': case 'C': case 'D': case 'E': + case 'F': case 'G': case 'H': case 'I': case 'J': + case 'K': case 'L': case 'M': case 'N': case 'O': + case 'P': case 'Q': case 'R': case 'S': case 'T': + case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': + case '-': case '.': case '_': case '~': + return GNUNET_NO; + default: + break; } return GNUNET_YES; } @@ -215,7 +216,7 @@ TALER_urlencode (const char *s) { if (GNUNET_YES == is_reserved (s[i])) { - snprintf(&out[t], 4, "%%%02X", s[i]); + snprintf (&out[t], 4, "%%%02X", s[i]); t += 2; continue; } @@ -305,7 +306,8 @@ TALER_url_join (const char *base_url, va_start (args, path); - while (1) { + while (1) + { char *key; char *value; key = va_arg (args, char *); @@ -360,7 +362,8 @@ url_absolute_raw_va (const char *proto, grow_string_path (&res, path, &n); - while (1) { + while (1) + { char *key; char *value; key = va_arg (args, char *); @@ -425,21 +428,23 @@ TALER_url_absolute_mhd (struct MHD_Connection *connection, { /* By default we assume we're running under HTTPS */ const char *proto = "https"; - const char *forwarded_proto = MHD_lookup_connection_value (connection, MHD_HEADER_KIND, "X-Forwarded-Proto"); + const char *forwarded_proto = MHD_lookup_connection_value (connection, + MHD_HEADER_KIND, + "X-Forwarded-Proto"); const char *host; const char *forwarded_host; const char *prefix; va_list args; char *result; - - + + if (NULL != forwarded_proto) { proto = forwarded_proto; } else { - /* likely not reverse proxy, figure out if we are + /* likely not reverse proxy, figure out if we are http by asking MHD */ const union MHD_ConnectionInfo *ci; @@ -459,9 +464,11 @@ TALER_url_absolute_mhd (struct MHD_Connection *connection, } } host = MHD_lookup_connection_value (connection, MHD_HEADER_KIND, "Host"); - forwarded_host = MHD_lookup_connection_value (connection, MHD_HEADER_KIND, "X-Forwarded-Host"); + forwarded_host = MHD_lookup_connection_value (connection, MHD_HEADER_KIND, + "X-Forwarded-Host"); - prefix = MHD_lookup_connection_value (connection, MHD_HEADER_KIND, "X-Forwarded-Prefix"); + prefix = MHD_lookup_connection_value (connection, MHD_HEADER_KIND, + "X-Forwarded-Prefix"); if (NULL == prefix) prefix = ""; diff --git a/src/wire-plugins/plugin_wire_ebics.c b/src/wire-plugins/plugin_wire_ebics.c index c2e0dc922..5482762a3 100644 --- a/src/wire-plugins/plugin_wire_ebics.c +++ b/src/wire-plugins/plugin_wire_ebics.c @@ -127,7 +127,8 @@ ebics_prepare_wire_transfer (void *cls, const char *destination_account_url, const struct TALER_Amount *amount, const char *exchange_base_url, - const struct TALER_WireTransferIdentifierRawP *wtid, + const struct + TALER_WireTransferIdentifierRawP *wtid, TALER_WIRE_PrepareTransactionCallback psc, void *psc_cls) { @@ -145,7 +146,7 @@ ebics_prepare_wire_transfer (void *cls, */ static void ebics_prepare_wire_transfer_cancel (void *cls, - struct TALER_WIRE_PrepareHandle *pth) + struct TALER_WIRE_PrepareHandle *pth) { GNUNET_break (0); // FIXME: not implemented } diff --git a/src/wire-plugins/plugin_wire_taler-bank.c b/src/wire-plugins/plugin_wire_taler-bank.c index 9aec4bd6d..6b92f4744 100644 --- a/src/wire-plugins/plugin_wire_taler-bank.c +++ b/src/wire-plugins/plugin_wire_taler-bank.c @@ -300,7 +300,8 @@ do_prepare (void *cls) TALER_amount_hton (&bf.amount, &pth->amount); { - char buf[sizeof (struct BufFormatP) + len_o + len_i + len_b + len_au + len_ap]; + char buf[sizeof (struct BufFormatP) + len_o + len_i + len_b + len_au + + len_ap]; memcpy (buf, &bf, @@ -415,7 +416,8 @@ taler_bank_prepare_wire_transfer (void *cls, const char *destination_account_url, const struct TALER_Amount *amount, const char *exchange_base_url, - const struct TALER_WireTransferIdentifierRawP *wtid, + const struct + TALER_WireTransferIdentifierRawP *wtid, TALER_WIRE_PrepareTransactionCallback ptc, void *ptc_cls) { @@ -458,7 +460,7 @@ taler_bank_prepare_wire_transfer (void *cls, if (TALER_EC_NONE != TALER_WIRE_payto_to_account (origin_account_url, &a_in)) - { + { GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR, origin_account_section, "URL", @@ -710,13 +712,16 @@ taler_bank_execute_wire_transfer (void *cls, wire_s = GNUNET_STRINGS_data_to_string_alloc (&bf.wtid, sizeof (bf.wtid)); eh->aaih = TALER_BANK_admin_add_incoming (tc->ctx, - origin_account.details.x_taler_bank.bank_base_url, + origin_account.details.x_taler_bank. + bank_base_url, &auth, exchange_base_url, wire_s, &amount, - (uint64_t) origin_account.details.x_taler_bank.no, - (uint64_t) destination_account.details.x_taler_bank.no, + (uint64_t) origin_account.details. + x_taler_bank.no, + (uint64_t) destination_account. + details.x_taler_bank.no, &execute_cb, eh); TALER_WIRE_account_free (&origin_account); @@ -830,7 +835,8 @@ bhist_cb (void *cls, uint64_t bserial_id = GNUNET_htonll (serial_id); struct TALER_WIRE_TransferDetails wd; - switch (http_status) { + switch (http_status) + { case MHD_HTTP_OK: { char *subject; @@ -1063,12 +1069,12 @@ taler_bank_get_history (void *cls, static struct TALER_WIRE_HistoryHandle * taler_bank_get_history_range (void *cls, - const char *account_section, - enum TALER_BANK_Direction direction, - struct GNUNET_TIME_Absolute start_date, - struct GNUNET_TIME_Absolute end_date, - TALER_WIRE_HistoryResultCallback hres_cb, - void *hres_cb_cls) + const char *account_section, + enum TALER_BANK_Direction direction, + struct GNUNET_TIME_Absolute start_date, + struct GNUNET_TIME_Absolute end_date, + TALER_WIRE_HistoryResultCallback hres_cb, + void *hres_cb_cls) { /* FIXME: remove the following lines when addressing #5746*/ @@ -1331,9 +1337,11 @@ libtaler_plugin_wire_taler_bank_init (void *cls) plugin->amount_round = &taler_bank_amount_round; plugin->wire_validate = &taler_bank_wire_validate; plugin->prepare_wire_transfer = &taler_bank_prepare_wire_transfer; - plugin->prepare_wire_transfer_cancel = &taler_bank_prepare_wire_transfer_cancel; + plugin->prepare_wire_transfer_cancel = + &taler_bank_prepare_wire_transfer_cancel; plugin->execute_wire_transfer = &taler_bank_execute_wire_transfer; - plugin->execute_wire_transfer_cancel = &taler_bank_execute_wire_transfer_cancel; + plugin->execute_wire_transfer_cancel = + &taler_bank_execute_wire_transfer_cancel; plugin->get_history = &taler_bank_get_history; plugin->get_history_range = &taler_bank_get_history_range; plugin->get_history_cancel = &taler_bank_get_history_cancel; diff --git a/src/wire-plugins/plugin_wire_template.c b/src/wire-plugins/plugin_wire_template.c index 6fadb88ce..0d0e652a1 100644 --- a/src/wire-plugins/plugin_wire_template.c +++ b/src/wire-plugins/plugin_wire_template.c @@ -109,7 +109,8 @@ template_prepare_wire_transfer (void *cls, const char *destination_account_url, const struct TALER_Amount *amount, const char *exchange_base_url, - const struct TALER_WireTransferIdentifierRawP *wtid, + const struct + TALER_WireTransferIdentifierRawP *wtid, TALER_WIRE_PrepareTransactionCallback ptc, void *ptc_cls) { @@ -220,7 +221,7 @@ template_get_history (void *cls, */ static void template_get_history_cancel (void *cls, - struct TALER_WIRE_HistoryHandle *whh) + struct TALER_WIRE_HistoryHandle *whh) { GNUNET_break (0); } diff --git a/src/wire-plugins/test_wire_plugin.c b/src/wire-plugins/test_wire_plugin.c index b29962b61..291ecbbec 100644 --- a/src/wire-plugins/test_wire_plugin.c +++ b/src/wire-plugins/test_wire_plugin.c @@ -29,7 +29,8 @@ /** * Definitions for a test with a plugin. */ -struct TestBlock { +struct TestBlock +{ /** * Name of the plugin to test. @@ -156,35 +157,35 @@ main (int argc, GNUNET_CONFIGURATION_load (cfg, "test_wire_plugin.conf")); ret = GNUNET_OK; - for (unsigned int i=0;NULL != (test = &tests[i])->plugin_name;i++) + for (unsigned int i = 0; NULL != (test = &tests[i])->plugin_name; i++) { GNUNET_CONFIGURATION_set_value_string (cfg, - "taler", - "CURRENCY", - test->currency); + "taler", + "CURRENCY", + test->currency); plugin = TALER_WIRE_plugin_load (cfg, test->plugin_name); if (NULL == plugin) { TALER_LOG_ERROR ("Could not load plugin `%s'\n", test->plugin_name); - return 77; + return 77; } - + ret = run_test (test, plugin); TALER_WIRE_plugin_unload (plugin); if (GNUNET_OK != ret) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "%s FAILED\n", - test->plugin_name); + "%s FAILED\n", + test->plugin_name); break; } else { GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, - "%s PASS\n", - test->plugin_name); + "%s PASS\n", + test->plugin_name); } } GNUNET_CONFIGURATION_destroy (cfg); diff --git a/src/wire-plugins/test_wire_plugin_transactions_taler-bank.c b/src/wire-plugins/test_wire_plugin_transactions_taler-bank.c index 4c2af52c4..304890dcb 100644 --- a/src/wire-plugins/test_wire_plugin_transactions_taler-bank.c +++ b/src/wire-plugins/test_wire_plugin_transactions_taler-bank.c @@ -163,11 +163,11 @@ timeout_cb (void *cls) static int history_result_cb (void *cls, - enum TALER_ErrorCode ec, - enum TALER_BANK_Direction dir, - const void *row_off, - size_t row_off_size, - const struct TALER_WIRE_TransferDetails *details) + enum TALER_ErrorCode ec, + enum TALER_BANK_Direction dir, + const void *row_off, + size_t row_off_size, + const struct TALER_WIRE_TransferDetails *details) { uint64_t *serialp; uint64_t serialh; diff --git a/src/wire/payto.c b/src/wire/payto.c index 8c62d86ee..5e762a864 100644 --- a/src/wire/payto.c +++ b/src/wire/payto.c @@ -79,152 +79,151 @@ struct CountryTableEntry /** * List of country codes. */ -static const struct CountryTableEntry country_table[] = - { - { "AE", "U.A.E." }, - { "AF", "Afghanistan" }, - { "AL", "Albania" }, - { "AM", "Armenia" }, - { "AN", "Netherlands Antilles" }, - { "AR", "Argentina" }, - { "AT", "Austria" }, - { "AU", "Australia" }, - { "AZ", "Azerbaijan" }, - { "BA", "Bosnia and Herzegovina" }, - { "BD", "Bangladesh" }, - { "BE", "Belgium" }, - { "BG", "Bulgaria" }, - { "BH", "Bahrain" }, - { "BN", "Brunei Darussalam" }, - { "BO", "Bolivia" }, - { "BR", "Brazil" }, - { "BT", "Bhutan" }, - { "BY", "Belarus" }, - { "BZ", "Belize" }, - { "CA", "Canada" }, - { "CG", "Congo" }, - { "CH", "Switzerland" }, - { "CI", "Cote d'Ivoire" }, - { "CL", "Chile" }, - { "CM", "Cameroon" }, - { "CN", "People's Republic of China" }, - { "CO", "Colombia" }, - { "CR", "Costa Rica" }, - { "CS", "Serbia and Montenegro" }, - { "CZ", "Czech Republic" }, - { "DE", "Germany" }, - { "DK", "Denmark" }, - { "DO", "Dominican Republic" }, - { "DZ", "Algeria" }, - { "EC", "Ecuador" }, - { "EE", "Estonia" }, - { "EG", "Egypt" }, - { "ER", "Eritrea" }, - { "ES", "Spain" }, - { "ET", "Ethiopia" }, - { "FI", "Finland" }, - { "FO", "Faroe Islands" }, - { "FR", "France" }, - { "GB", "United Kingdom" }, - { "GD", "Caribbean" }, - { "GE", "Georgia" }, - { "GL", "Greenland" }, - { "GR", "Greece" }, - { "GT", "Guatemala" }, - { "HK", "Hong Kong" }, - { "HK", "Hong Kong S.A.R." }, - { "HN", "Honduras" }, - { "HR", "Croatia" }, - { "HT", "Haiti" }, - { "HU", "Hungary" }, - { "ID", "Indonesia" }, - { "IE", "Ireland" }, - { "IL", "Israel" }, - { "IN", "India" }, - { "IQ", "Iraq" }, - { "IR", "Iran" }, - { "IS", "Iceland" }, - { "IT", "Italy" }, - { "JM", "Jamaica" }, - { "JO", "Jordan" }, - { "JP", "Japan" }, - { "KE", "Kenya" }, - { "KG", "Kyrgyzstan" }, - { "KH", "Cambodia" }, - { "KR", "South Korea" }, - { "KW", "Kuwait" }, - { "KZ", "Kazakhstan" }, - { "LA", "Laos" }, - { "LB", "Lebanon" }, - { "LI", "Liechtenstein" }, - { "LK", "Sri Lanka" }, - { "LT", "Lithuania" }, - { "LU", "Luxembourg" }, - { "LV", "Latvia" }, - { "LY", "Libya" }, - { "MA", "Morocco" }, - { "MC", "Principality of Monaco" }, - { "MD", "Moldava" }, - { "MD", "Moldova" }, - { "ME", "Montenegro" }, - { "MK", "Former Yugoslav Republic of Macedonia" }, - { "ML", "Mali" }, - { "MM", "Myanmar" }, - { "MN", "Mongolia" }, - { "MO", "Macau S.A.R." }, - { "MT", "Malta" }, - { "MV", "Maldives" }, - { "MX", "Mexico" }, - { "MY", "Malaysia" }, - { "NG", "Nigeria" }, - { "NI", "Nicaragua" }, - { "NL", "Netherlands" }, - { "NO", "Norway" }, - { "NP", "Nepal" }, - { "NZ", "New Zealand" }, - { "OM", "Oman" }, - { "PA", "Panama" }, - { "PE", "Peru" }, - { "PH", "Philippines" }, - { "PK", "Islamic Republic of Pakistan" }, - { "PL", "Poland" }, - { "PR", "Puerto Rico" }, - { "PT", "Portugal" }, - { "PY", "Paraguay" }, - { "QA", "Qatar" }, - { "RE", "Reunion" }, - { "RO", "Romania" }, - { "RS", "Serbia" }, - { "RU", "Russia" }, - { "RW", "Rwanda" }, - { "SA", "Saudi Arabia" }, - { "SE", "Sweden" }, - { "SG", "Singapore" }, - { "SI", "Slovenia" }, - { "SK", "Slovak" }, - { "SN", "Senegal" }, - { "SO", "Somalia" }, - { "SR", "Suriname" }, - { "SV", "El Salvador" }, - { "SY", "Syria" }, - { "TH", "Thailand" }, - { "TJ", "Tajikistan" }, - { "TM", "Turkmenistan" }, - { "TN", "Tunisia" }, - { "TR", "Turkey" }, - { "TT", "Trinidad and Tobago" }, - { "TW", "Taiwan" }, - { "TZ", "Tanzania" }, - { "UA", "Ukraine" }, - { "US", "United States" }, - { "UY", "Uruguay" }, - { "VA", "Vatican" }, - { "VE", "Venezuela" }, - { "VN", "Viet Nam" }, - { "YE", "Yemen" }, - { "ZA", "South Africa" }, - { "ZW", "Zimbabwe" } - }; +static const struct CountryTableEntry country_table[] = { + { "AE", "U.A.E." }, + { "AF", "Afghanistan" }, + { "AL", "Albania" }, + { "AM", "Armenia" }, + { "AN", "Netherlands Antilles" }, + { "AR", "Argentina" }, + { "AT", "Austria" }, + { "AU", "Australia" }, + { "AZ", "Azerbaijan" }, + { "BA", "Bosnia and Herzegovina" }, + { "BD", "Bangladesh" }, + { "BE", "Belgium" }, + { "BG", "Bulgaria" }, + { "BH", "Bahrain" }, + { "BN", "Brunei Darussalam" }, + { "BO", "Bolivia" }, + { "BR", "Brazil" }, + { "BT", "Bhutan" }, + { "BY", "Belarus" }, + { "BZ", "Belize" }, + { "CA", "Canada" }, + { "CG", "Congo" }, + { "CH", "Switzerland" }, + { "CI", "Cote d'Ivoire" }, + { "CL", "Chile" }, + { "CM", "Cameroon" }, + { "CN", "People's Republic of China" }, + { "CO", "Colombia" }, + { "CR", "Costa Rica" }, + { "CS", "Serbia and Montenegro" }, + { "CZ", "Czech Republic" }, + { "DE", "Germany" }, + { "DK", "Denmark" }, + { "DO", "Dominican Republic" }, + { "DZ", "Algeria" }, + { "EC", "Ecuador" }, + { "EE", "Estonia" }, + { "EG", "Egypt" }, + { "ER", "Eritrea" }, + { "ES", "Spain" }, + { "ET", "Ethiopia" }, + { "FI", "Finland" }, + { "FO", "Faroe Islands" }, + { "FR", "France" }, + { "GB", "United Kingdom" }, + { "GD", "Caribbean" }, + { "GE", "Georgia" }, + { "GL", "Greenland" }, + { "GR", "Greece" }, + { "GT", "Guatemala" }, + { "HK", "Hong Kong" }, + { "HK", "Hong Kong S.A.R." }, + { "HN", "Honduras" }, + { "HR", "Croatia" }, + { "HT", "Haiti" }, + { "HU", "Hungary" }, + { "ID", "Indonesia" }, + { "IE", "Ireland" }, + { "IL", "Israel" }, + { "IN", "India" }, + { "IQ", "Iraq" }, + { "IR", "Iran" }, + { "IS", "Iceland" }, + { "IT", "Italy" }, + { "JM", "Jamaica" }, + { "JO", "Jordan" }, + { "JP", "Japan" }, + { "KE", "Kenya" }, + { "KG", "Kyrgyzstan" }, + { "KH", "Cambodia" }, + { "KR", "South Korea" }, + { "KW", "Kuwait" }, + { "KZ", "Kazakhstan" }, + { "LA", "Laos" }, + { "LB", "Lebanon" }, + { "LI", "Liechtenstein" }, + { "LK", "Sri Lanka" }, + { "LT", "Lithuania" }, + { "LU", "Luxembourg" }, + { "LV", "Latvia" }, + { "LY", "Libya" }, + { "MA", "Morocco" }, + { "MC", "Principality of Monaco" }, + { "MD", "Moldava" }, + { "MD", "Moldova" }, + { "ME", "Montenegro" }, + { "MK", "Former Yugoslav Republic of Macedonia" }, + { "ML", "Mali" }, + { "MM", "Myanmar" }, + { "MN", "Mongolia" }, + { "MO", "Macau S.A.R." }, + { "MT", "Malta" }, + { "MV", "Maldives" }, + { "MX", "Mexico" }, + { "MY", "Malaysia" }, + { "NG", "Nigeria" }, + { "NI", "Nicaragua" }, + { "NL", "Netherlands" }, + { "NO", "Norway" }, + { "NP", "Nepal" }, + { "NZ", "New Zealand" }, + { "OM", "Oman" }, + { "PA", "Panama" }, + { "PE", "Peru" }, + { "PH", "Philippines" }, + { "PK", "Islamic Republic of Pakistan" }, + { "PL", "Poland" }, + { "PR", "Puerto Rico" }, + { "PT", "Portugal" }, + { "PY", "Paraguay" }, + { "QA", "Qatar" }, + { "RE", "Reunion" }, + { "RO", "Romania" }, + { "RS", "Serbia" }, + { "RU", "Russia" }, + { "RW", "Rwanda" }, + { "SA", "Saudi Arabia" }, + { "SE", "Sweden" }, + { "SG", "Singapore" }, + { "SI", "Slovenia" }, + { "SK", "Slovak" }, + { "SN", "Senegal" }, + { "SO", "Somalia" }, + { "SR", "Suriname" }, + { "SV", "El Salvador" }, + { "SY", "Syria" }, + { "TH", "Thailand" }, + { "TJ", "Tajikistan" }, + { "TM", "Turkmenistan" }, + { "TN", "Tunisia" }, + { "TR", "Turkey" }, + { "TT", "Trinidad and Tobago" }, + { "TW", "Taiwan" }, + { "TZ", "Tanzania" }, + { "UA", "Ukraine" }, + { "US", "United States" }, + { "UY", "Uruguay" }, + { "VA", "Vatican" }, + { "VE", "Venezuela" }, + { "VN", "Viet Nam" }, + { "YE", "Yemen" }, + { "ZA", "South Africa" }, + { "ZW", "Zimbabwe" } +}; /** @@ -296,14 +295,14 @@ validate_iban (const char *iban) return GNUNET_NO; } nbuf = GNUNET_malloc ((len * 2) + 1); - for (i=0, j=0; i < len; i++) + for (i = 0, j = 0; i < len; i++) { if (isalpha ((unsigned char) ibancpy[i])) { - if (2 != snprintf(&nbuf[j], - 3, - "%2u", - (ibancpy[i] - 'A' + 10))) + if (2 != snprintf (&nbuf[j], + 3, + "%2u", + (ibancpy[i] - 'A' + 10))) { GNUNET_free (nbuf); return GNUNET_NO; @@ -314,11 +313,11 @@ validate_iban (const char *iban) nbuf[j] = ibancpy[i]; j++; } - for (j=0;'\0' != nbuf[j];j++) - GNUNET_assert (isdigit( (unsigned char) nbuf[j])); + for (j = 0; '\0' != nbuf[j]; j++) + GNUNET_assert (isdigit ( (unsigned char) nbuf[j])); GNUNET_assert (sizeof(dividend) >= 8); remainder = 0; - for (unsigned int i=0; idetails.x_taler_bank.no = no; port = 443; /* if non given, equals 443. */ if (NULL != (p = strchr (r_account->details.x_taler_bank.hostname, - (unsigned char) ':'))) + (unsigned char) ':'))) { p++; if (1 != sscanf (p, @@ -478,16 +477,16 @@ parse_payto_x_taler_bank (const char *account_url, GNUNET_assert (GNUNET_SYSERR != GNUNET_asprintf (&r_account->details.x_taler_bank.bank_base_url, - "http://%s", - r_account->details.x_taler_bank.hostname)); + "http://%s", + r_account->details.x_taler_bank.hostname)); } else { GNUNET_assert (GNUNET_SYSERR != GNUNET_asprintf (&r_account->details.x_taler_bank.bank_base_url, - "https://%s", - r_account->details.x_taler_bank.hostname)); + "https://%s", + r_account->details.x_taler_bank.hostname)); } r_account->type = TALER_PAC_X_TALER_BANK; } @@ -496,8 +495,8 @@ parse_payto_x_taler_bank (const char *account_url, typedef enum TALER_ErrorCode -(*Parser) (const char *account_url, - struct TALER_Account *r_account); +(*Parser)(const char *account_url, + struct TALER_Account *r_account); /** * Parse @a payto_url and store the result in @a acc @@ -516,7 +515,7 @@ TALER_WIRE_payto_to_account (const char *payto_url, NULL }; - for (unsigned int i=0;NULL != parsers[i];i++) + for (unsigned int i = 0; NULL != parsers[i]; i++) { enum TALER_ErrorCode ec = parsers[i](payto_url, acc); diff --git a/src/wire/wire_helper.c b/src/wire/wire_helper.c index 0ce8d599a..e5ca8b168 100644 --- a/src/wire/wire_helper.c +++ b/src/wire/wire_helper.c @@ -65,7 +65,7 @@ TALER_WIRE_payto_get_method (const char *payto_url) PAYTO, strlen (PAYTO))) return NULL; - start = &payto_url[strlen(PAYTO)]; + start = &payto_url[strlen (PAYTO)]; end = strchr (start, (unsigned char) '/'); if (NULL == end) @@ -91,7 +91,7 @@ TALER_WIRE_get_plugin_from_method (const char *method) {NULL, NULL} }; - for (unsigned int i=0; + for (unsigned int i = 0; NULL != ct[i].method; i++) { -- cgit v1.2.3