diff options
author | Christian Grothoff <christian@grothoff.org> | 2019-10-05 15:51:29 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2019-10-05 15:51:29 +0200 |
commit | 6a0d1b7df0afefa5468c35c7bcbb4a0fa3a0b46e (patch) | |
tree | 9e2aa0cbdfde705bafcfa71bc88442a8b073ad5b | |
parent | 54bde12c0295e008e050a8418c4702b8f3ea4a55 (diff) | |
download | merchant-6a0d1b7df0afefa5468c35c7bcbb4a0fa3a0b46e.tar.gz merchant-6a0d1b7df0afefa5468c35c7bcbb4a0fa3a0b46e.tar.bz2 merchant-6a0d1b7df0afefa5468c35c7bcbb4a0fa3a0b46e.zip |
reindenting with uncrustify
33 files changed, 1473 insertions, 1317 deletions
diff --git a/src/backend/taler-merchant-httpd_auditors.c b/src/backend/taler-merchant-httpd_auditors.c index f4dea05a..9aab2374 100644 --- a/src/backend/taler-merchant-httpd_auditors.c +++ b/src/backend/taler-merchant-httpd_auditors.c @@ -96,10 +96,10 @@ TMH_AUDITORS_check_dk (struct TALER_EXCHANGE_Handle *mh, GNUNET_break (0); return GNUNET_SYSERR; } - for (unsigned int i=0;i<keys->num_auditors;i++) + for (unsigned int i = 0; i<keys->num_auditors; i++) { ai = &keys->auditors[i]; - for (unsigned int j=0;j<nauditors;j++) + for (unsigned int j = 0; j<nauditors; j++) { if (0 == GNUNET_memcmp (&ai->auditor_pub, &auditors[j].public_key)) @@ -110,7 +110,7 @@ TMH_AUDITORS_check_dk (struct TALER_EXCHANGE_Handle *mh, TALER_B2S (&auditors[j].public_key)); } - for (unsigned int k=0;j<ai->num_denom_keys;k++) + for (unsigned int k = 0; j<ai->num_denom_keys; k++) if (&keys->denom_keys[k] == dk) return GNUNET_OK; } @@ -243,8 +243,11 @@ TMH_AUDITORS_init (const struct GNUNET_CONFIGURATION_Handle *cfg) json_array_append_new (j_auditors, json_pack ("{s:s, s:o, s:s}", "name", auditors[cnt].name, - "auditor_pub", GNUNET_JSON_from_data_auto (&auditors[cnt].public_key), - "url", auditors[cnt].url))); + "auditor_pub", + GNUNET_JSON_from_data_auto ( + &auditors[cnt].public_key), + "url", + auditors[cnt].url))); return nauditors; } @@ -257,7 +260,7 @@ TMH_AUDITORS_done () { json_decref (j_auditors); j_auditors = NULL; - for (unsigned int i=0;i<nauditors;i++) + for (unsigned int i = 0; i<nauditors; i++) { GNUNET_free (auditors[i].name); GNUNET_free (auditors[i].url); diff --git a/src/backend/taler-merchant-httpd_exchanges.c b/src/backend/taler-merchant-httpd_exchanges.c index ed6ece98..a589fbaa 100644 --- a/src/backend/taler-merchant-httpd_exchanges.c +++ b/src/backend/taler-merchant-httpd_exchanges.c @@ -34,7 +34,8 @@ /** * Threshold after which exponential backoff should not increase. */ -#define RETRY_BACKOFF_THRESHOLD GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 60) +#define RETRY_BACKOFF_THRESHOLD GNUNET_TIME_relative_multiply ( \ + GNUNET_TIME_UNIT_SECONDS, 60) /** @@ -44,7 +45,10 @@ * @param r current backoff time, initially zero */ #define RETRY_BACKOFF(r) GNUNET_TIME_relative_min (RETRY_BACKOFF_THRESHOLD, \ - GNUNET_TIME_relative_multiply (GNUNET_TIME_relative_max (GNUNET_TIME_UNIT_MILLISECONDS, (r)), 2)); + GNUNET_TIME_relative_multiply ( \ + GNUNET_TIME_relative_max ( \ + GNUNET_TIME_UNIT_MILLISECONDS, \ + (r)), 2)); /** @@ -261,7 +265,7 @@ json_t *trusted_exchanges; static void keys_mgmt_cb (void *cls, const struct TALER_EXCHANGE_Keys *keys, - enum TALER_EXCHANGE_VersionCompatibility compat); + enum TALER_EXCHANGE_VersionCompatibility compat); /** @@ -349,36 +353,36 @@ process_wire_fees (struct Exchange *exchange, af = GNUNET_new (struct TALER_EXCHANGE_WireAggregateFees); *af = *fees; GNUNET_CRYPTO_hash (wire_method, - strlen (wire_method) + 1, - &h_wire_method); + strlen (wire_method) + 1, + &h_wire_method); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Storing wire fee for `%s' and method `%s' at %s in DB; the fee is %s\n", - TALER_B2S (master_pub), - wire_method, - GNUNET_STRINGS_absolute_time_to_string (af->start_date), - TALER_amount2s (&af->wire_fee)); + "Storing wire fee for `%s' and method `%s' at %s in DB; the fee is %s\n", + TALER_B2S (master_pub), + wire_method, + GNUNET_STRINGS_absolute_time_to_string (af->start_date), + TALER_amount2s (&af->wire_fee)); db->preflight (db->cls); if (GNUNET_OK != db->start (db->cls, "store wire fee")) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Failed to start database transaction!\n"); + "Failed to start database transaction!\n"); GNUNET_free (af); return GNUNET_SYSERR; } qs = db->store_wire_fee_by_exchange (db->cls, - master_pub, - &h_wire_method, - &af->wire_fee, - &af->closing_fee, - af->start_date, - af->end_date, - &af->master_sig); + master_pub, + &h_wire_method, + &af->wire_fee, + &af->closing_fee, + af->start_date, + af->end_date, + &af->master_sig); if (0 > qs) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Failed to persist exchange wire fees in merchant DB!\n"); + "Failed to persist exchange wire fees in merchant DB!\n"); GNUNET_free (af); fees = fees->next; db->rollback (db->cls); @@ -388,7 +392,7 @@ process_wire_fees (struct Exchange *exchange, { /* Entry was already in DB, fine, continue as if we had succeeded */ GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "Fees already in DB, rolling back transaction attempt!\n"); + "Fees already in DB, rolling back transaction attempt!\n"); db->rollback (db->cls); } if (0 < qs) @@ -434,7 +438,7 @@ process_wire_accounts (struct Exchange *exchange, unsigned int accounts_len, const struct TALER_EXCHANGE_WireAccount *accounts) { - for (unsigned int i=0;i<accounts_len;i++) + for (unsigned int i = 0; i<accounts_len; i++) { char *method; @@ -532,8 +536,9 @@ process_find_operations (struct Exchange *exchange) /* Disagreement on the current time */ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Exchange's earliest fee is %s adhead of our time. Clock skew issue?\n", - GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_remaining (af->start_date), - GNUNET_YES)); + GNUNET_STRINGS_relative_time_to_string ( + GNUNET_TIME_absolute_get_remaining (af->start_date), + GNUNET_YES)); continue; } /* found fee, great! */ @@ -651,9 +656,10 @@ handle_wire_data (void *cls, "Do not have sufficient wire data. Will re-request /wire in 1 minute\n"); GNUNET_assert (NULL == exchange->wire_task); - exchange->wire_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES, - &wire_task_cb, - exchange); + exchange->wire_task = GNUNET_SCHEDULER_add_delayed ( + GNUNET_TIME_UNIT_MINUTES, + &wire_task_cb, + exchange); } } @@ -700,7 +706,7 @@ wire_task_cb (void *cls) static void keys_mgmt_cb (void *cls, const struct TALER_EXCHANGE_Keys *keys, - enum TALER_EXCHANGE_VersionCompatibility compat) + enum TALER_EXCHANGE_VersionCompatibility compat) { struct Exchange *exchange = cls; struct GNUNET_TIME_Absolute expire; @@ -723,8 +729,8 @@ keys_mgmt_cb (void *cls, { /* Give up, log hard error. */ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Exchange `%s' runs an incompatible more recent version of the Taler protocol. Will not retry. This client may need to be updated.\n", - exchange->url); + "Exchange `%s' runs an incompatible more recent version of the Taler protocol. Will not retry. This client may need to be updated.\n", + exchange->url); return; } exchange->retry_delay = RETRY_BACKOFF (exchange->retry_delay); @@ -748,8 +754,8 @@ keys_mgmt_cb (void *cls, { once = 1; GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - "Exchange `%s' runs a more recent version of the Taler protocol. You may want to update this client.\n", - exchange->url); + "Exchange `%s' runs a more recent version of the Taler protocol. You may want to update this client.\n", + exchange->url); } } expire = TALER_EXCHANGE_check_keys_current (exchange->conn, @@ -824,8 +830,8 @@ return_result (void *cls) struct TMH_EXCHANGES_FindOperation * TMH_EXCHANGES_find_exchange (const char *chosen_exchange, const char *wire_method, - TMH_EXCHANGES_FindContinuation fc, - void *fc_cls) + TMH_EXCHANGES_FindContinuation fc, + void *fc_cls) { struct Exchange *exchange; struct TMH_EXCHANGES_FindOperation *fo; @@ -843,8 +849,8 @@ TMH_EXCHANGES_find_exchange (const char *chosen_exchange, /* Check if the exchange is known */ for (exchange = exchange_head; NULL != exchange; exchange = exchange->next) - /* test it by checking public key --- FIXME: hostname or public key!? - Should probably be URL, not hostname anyway! */ + /* test it by checking public key --- FIXME: hostname or public key!? + Should probably be URL, not hostname anyway! */ { if (0 == strcmp (exchange->url, chosen_exchange)) @@ -934,7 +940,7 @@ TMH_EXCHANGES_find_exchange_cancel (struct TMH_EXCHANGES_FindOperation *fo) { GNUNET_SCHEDULER_cancel (fo->at); fo->at = NULL; - } + } GNUNET_CONTAINER_DLL_remove (exchange->fo_head, exchange->fo_tail, fo); @@ -1008,7 +1014,8 @@ accept_exchanges (void *cls, if (GNUNET_OK == GNUNET_CRYPTO_eddsa_public_key_from_string (mks, strlen (mks), - &exchange->master_pub.eddsa_pub)) + &exchange->master_pub. + eddsa_pub)) { exchange->trusted = GNUNET_YES; } @@ -1017,7 +1024,7 @@ accept_exchanges (void *cls, GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR, section, "MASTER_KEY", - _("ill-formed key")); + _ ("ill-formed key")); } GNUNET_free (mks); } @@ -1056,7 +1063,8 @@ TMH_EXCHANGES_init (const struct GNUNET_CONFIGURATION_Handle *cfg) GNUNET_break (0); return GNUNET_SYSERR; } - GNUNET_CURL_enable_async_scope_header (merchant_curl_ctx, "Taler-Correlation-Id"); + GNUNET_CURL_enable_async_scope_header (merchant_curl_ctx, + "Taler-Correlation-Id"); merchant_curl_rc = GNUNET_CURL_gnunet_rc_create (merchant_curl_ctx); /* get exchanges from the merchant configuration and try to connect to them */ GNUNET_CONFIGURATION_iterate_sections (cfg, @@ -1074,7 +1082,8 @@ TMH_EXCHANGES_init (const struct GNUNET_CONFIGURATION_Handle *cfg) continue; j_exchange = json_pack ("{s:s, s:o}", "url", exchange->url, - "master_pub", GNUNET_JSON_from_data_auto (&exchange->master_pub)); + "master_pub", GNUNET_JSON_from_data_auto ( + &exchange->master_pub)); GNUNET_assert (0 == json_array_append_new (trusted_exchanges, j_exchange)); diff --git a/src/backend/taler-merchant-httpd_parsing.c b/src/backend/taler-merchant-httpd_parsing.c index 743999df..7e21482a 100644 --- a/src/backend/taler-merchant-httpd_parsing.c +++ b/src/backend/taler-merchant-httpd_parsing.c @@ -37,12 +37,12 @@ /** * Initial size for POST request buffer. */ -#define REQUEST_BUFFER_INITIAL (2*1024) +#define REQUEST_BUFFER_INITIAL (2 * 1024) /** * Maximum POST request size. */ -#define REQUEST_BUFFER_MAX (1024*1024) +#define REQUEST_BUFFER_MAX (1024 * 1024) /** @@ -147,21 +147,21 @@ TMH_PARSE_post_json (struct MHD_Connection *connection, case GNUNET_JSON_PR_OUT_OF_MEMORY: return (MHD_NO == TMH_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 == TMH_RESPONSE_reply_request_too_large - (connection)) ? GNUNET_SYSERR : GNUNET_NO; + (connection)) ? GNUNET_SYSERR : GNUNET_NO; case GNUNET_JSON_PR_JSON_INVALID: return (MHD_YES == TMH_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; @@ -213,7 +213,7 @@ TMH_PARSE_json_data (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; @@ -251,9 +251,9 @@ TMH_PARSE_mhd_request_arg_data (struct MHD_Connection *connection, { return (MHD_NO == TMH_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, @@ -262,9 +262,9 @@ TMH_PARSE_mhd_request_arg_data (struct MHD_Connection *connection, out_size)) return (MHD_NO == TMH_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; } diff --git a/src/backend/taler-merchant-httpd_responses.c b/src/backend/taler-merchant-httpd_responses.c index 2b5832f6..9c847f3a 100644 --- a/src/backend/taler-merchant-httpd_responses.c +++ b/src/backend/taler-merchant-httpd_responses.c @@ -43,7 +43,7 @@ TMH_RESPONSE_make_json (const json_t *json) char *json_str; json_str = json_dumps (json, - JSON_INDENT(2)); + JSON_INDENT (2)); if (NULL == json_str) { GNUNET_break (0); @@ -111,9 +111,9 @@ TMH_RESPONSE_make_json_pack (const char *fmt, va_start (argp, fmt); json = json_vpack_ex (&jerror, - 0, - fmt, - argp); + 0, + fmt, + argp); va_end (argp); if (NULL == json) { @@ -273,7 +273,8 @@ TMH_RESPONSE_reply_invalid_json (struct MHD_Connection *connection) return TMH_RESPONSE_reply_json_pack (connection, MHD_HTTP_BAD_REQUEST, "{s:I, s:s}", - "code", (json_int_t) TALER_EC_JSON_INVALID, + "code", + (json_int_t) TALER_EC_JSON_INVALID, "error", "invalid json"); } diff --git a/src/backend/taler-merchant-httpd_responses.h b/src/backend/taler-merchant-httpd_responses.h index 3dbd0049..708185c9 100644 --- a/src/backend/taler-merchant-httpd_responses.h +++ b/src/backend/taler-merchant-httpd_responses.h @@ -124,7 +124,7 @@ TMH_RESPONSE_reply_rc (struct MHD_Connection *connection, */ int TMH_RESPONSE_reply_not_found (struct MHD_Connection *connection, - enum TALER_ErrorCode ec, + enum TALER_ErrorCode ec, const char *object); @@ -138,7 +138,7 @@ TMH_RESPONSE_reply_not_found (struct MHD_Connection *connection, */ int TMH_RESPONSE_reply_bad_request (struct MHD_Connection *connection, - enum TALER_ErrorCode ec, + enum TALER_ErrorCode ec, const char *issue); @@ -151,7 +151,7 @@ TMH_RESPONSE_reply_bad_request (struct MHD_Connection *connection, */ struct MHD_Response * TMH_RESPONSE_make_internal_error (enum TALER_ErrorCode ec, - const char *hint); + const char *hint); /** @@ -164,7 +164,7 @@ TMH_RESPONSE_make_internal_error (enum TALER_ErrorCode ec, */ int TMH_RESPONSE_reply_external_error (struct MHD_Connection *connection, - enum TALER_ErrorCode ec, + enum TALER_ErrorCode ec, const char *hint); @@ -178,7 +178,7 @@ TMH_RESPONSE_reply_external_error (struct MHD_Connection *connection, */ int TMH_RESPONSE_reply_internal_error (struct MHD_Connection *connection, - enum TALER_ErrorCode ec, + enum TALER_ErrorCode ec, const char *hint); @@ -191,7 +191,7 @@ TMH_RESPONSE_reply_internal_error (struct MHD_Connection *connection, */ struct MHD_Response * TMH_RESPONSE_make_error (enum TALER_ErrorCode ec, - const char *hint); + const char *hint); /** @@ -225,7 +225,7 @@ TMH_RESPONSE_add_global_headers (struct MHD_Response *response); */ int TMH_RESPONSE_reply_arg_missing (struct MHD_Connection *connection, - enum TALER_ErrorCode ec, + enum TALER_ErrorCode ec, const char *param_name); @@ -239,7 +239,7 @@ TMH_RESPONSE_reply_arg_missing (struct MHD_Connection *connection, */ int TMH_RESPONSE_reply_arg_invalid (struct MHD_Connection *connection, - enum TALER_ErrorCode ec, + enum TALER_ErrorCode ec, const char *param_name); #endif diff --git a/src/backend/taler-merchant-httpd_tip-reserve-helper.c b/src/backend/taler-merchant-httpd_tip-reserve-helper.c index 1cf721cd..413eefc8 100644 --- a/src/backend/taler-merchant-httpd_tip-reserve-helper.c +++ b/src/backend/taler-merchant-httpd_tip-reserve-helper.c @@ -121,8 +121,9 @@ handle_status (void *cls, GNUNET_break_op (0); resume_with_response (ctr, MHD_HTTP_SERVICE_UNAVAILABLE, - TMH_RESPONSE_make_error (TALER_EC_TIP_QUERY_RESERVE_HISTORY_FAILED_EMPTY, - "Exchange returned empty reserve history")); + TMH_RESPONSE_make_error ( + TALER_EC_TIP_QUERY_RESERVE_HISTORY_FAILED_EMPTY, + "Exchange returned empty reserve history")); return; } @@ -131,8 +132,9 @@ handle_status (void *cls, GNUNET_break_op (0); resume_with_response (ctr, MHD_HTTP_SERVICE_UNAVAILABLE, - TMH_RESPONSE_make_error (TALER_EC_TIP_QUERY_RESERVE_HISTORY_INVALID_NO_DEPOSIT, - "Exchange returned invalid reserve history")); + TMH_RESPONSE_make_error ( + TALER_EC_TIP_QUERY_RESERVE_HISTORY_INVALID_NO_DEPOSIT, + "Exchange returned invalid reserve history")); return; } @@ -143,8 +145,9 @@ handle_status (void *cls, GNUNET_break_op (0); resume_with_response (ctr, MHD_HTTP_SERVICE_UNAVAILABLE, - TMH_RESPONSE_make_error (TALER_EC_TIP_QUERY_RESERVE_HISTORY_INVALID_CURRENCY, - "Exchange returned invalid reserve history")); + TMH_RESPONSE_make_error ( + TALER_EC_TIP_QUERY_RESERVE_HISTORY_INVALID_CURRENCY, + "Exchange returned invalid reserve history")); return; } @@ -154,8 +157,9 @@ handle_status (void *cls, GNUNET_break_op (0); resume_with_response (ctr, MHD_HTTP_SERVICE_UNAVAILABLE, - TMH_RESPONSE_make_error (TALER_EC_TIP_QUERY_RESERVE_CURRENCY_MISSMATCH, - "Exchange currency unexpected")); + TMH_RESPONSE_make_error ( + TALER_EC_TIP_QUERY_RESERVE_CURRENCY_MISSMATCH, + "Exchange currency unexpected")); return; } @@ -164,7 +168,7 @@ handle_status (void *cls, ctr->amount_deposited = ctr->amount_withdrawn; /* Update DB based on status! */ - for (unsigned int i=0;i<history_length;i++) + for (unsigned int i = 0; i<history_length; i++) { switch (history[i].type) { @@ -174,12 +178,15 @@ handle_status (void *cls, struct GNUNET_HashCode uuid; struct GNUNET_TIME_Absolute deposit_expiration; - deposit_expiration = GNUNET_TIME_absolute_add (history[i].details.in_details.timestamp, - ctr->idle_reserve_expiration_time); + deposit_expiration = GNUNET_TIME_absolute_add ( + history[i].details.in_details.timestamp, + ctr-> + idle_reserve_expiration_time); /* We're interested in the latest DEPOSIT timestamp, since this determines the * reserve's expiration date. Note that the history isn't chronologically ordered. */ - ctr->reserve_expiration = GNUNET_TIME_absolute_max (ctr->reserve_expiration, - deposit_expiration); + ctr->reserve_expiration = GNUNET_TIME_absolute_max ( + ctr->reserve_expiration, + deposit_expiration); GNUNET_CRYPTO_hash (history[i].details.in_details.wire_reference, history[i].details.in_details.wire_reference_size, &uuid); @@ -197,15 +204,17 @@ handle_status (void *cls, GNUNET_break_op (0); resume_with_response (ctr, MHD_HTTP_INTERNAL_SERVER_ERROR, - TMH_RESPONSE_make_error (TALER_EC_TIP_QUERY_RESERVE_HISTORY_ARITHMETIC_ISSUE_DEPOSIT, - "Exchange returned invalid reserve history (amount overflow)")); + TMH_RESPONSE_make_error ( + TALER_EC_TIP_QUERY_RESERVE_HISTORY_ARITHMETIC_ISSUE_DEPOSIT, + "Exchange returned invalid reserve history (amount overflow)")); return; } if (0 > qs) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - _("Database error updating tipping reserve status: %d\n"), + _ ( + "Database error updating tipping reserve status: %d\n"), qs); } } @@ -219,14 +228,16 @@ handle_status (void *cls, GNUNET_break_op (0); resume_with_response (ctr, MHD_HTTP_INTERNAL_SERVER_ERROR, - TMH_RESPONSE_make_error (TALER_EC_TIP_QUERY_RESERVE_HISTORY_ARITHMETIC_ISSUE_WITHDRAW, - "Exchange returned invalid reserve history (amount overflow)")); + TMH_RESPONSE_make_error ( + TALER_EC_TIP_QUERY_RESERVE_HISTORY_ARITHMETIC_ISSUE_WITHDRAW, + "Exchange returned invalid reserve history (amount overflow)")); return; } break; case TALER_EXCHANGE_RTT_PAYBACK: GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - _("Encountered unsupported /payback operation on tipping reserve\n")); + _ ( + "Encountered unsupported /payback operation on tipping reserve\n")); /* FIXME: probably should count these like deposits!? */ break; case TALER_EXCHANGE_RTT_CLOSE: @@ -239,8 +250,9 @@ handle_status (void *cls, GNUNET_break_op (0); resume_with_response (ctr, MHD_HTTP_INTERNAL_SERVER_ERROR, - TMH_RESPONSE_make_error (TALER_EC_TIP_QUERY_RESERVE_HISTORY_ARITHMETIC_ISSUE_CLOSED, - "Exchange returned invalid reserve history (amount overflow)")); + TMH_RESPONSE_make_error ( + TALER_EC_TIP_QUERY_RESERVE_HISTORY_ARITHMETIC_ISSUE_CLOSED, + "Exchange returned invalid reserve history (amount overflow)")); return; } break; @@ -278,11 +290,12 @@ exchange_cont (void *cls, if (NULL == eh) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - _("Failed to contact exchange configured for tipping!\n")); + _ ("Failed to contact exchange configured for tipping!\n")); resume_with_response (ctr, MHD_HTTP_SERVICE_UNAVAILABLE, - TMH_RESPONSE_make_error (TALER_EC_TIP_QUERY_RESERVE_STATUS_FAILED_EXCHANGE_DOWN, - "Unable to obtain /keys from exchange")); + TMH_RESPONSE_make_error ( + TALER_EC_TIP_QUERY_RESERVE_STATUS_FAILED_EXCHANGE_DOWN, + "Unable to obtain /keys from exchange")); return; } keys = TALER_EXCHANGE_get_keys (eh); @@ -326,8 +339,9 @@ TMH_check_tip_reserve (struct CheckTipReserve *ctr, GNUNET_break (0); resume_with_response (ctr, MHD_HTTP_INTERNAL_SERVER_ERROR, - TMH_RESPONSE_make_error (TALER_EC_INTERNAL_INVARIANT_FAILURE, - "Unable to find exchange handle")); + TMH_RESPONSE_make_error ( + TALER_EC_INTERNAL_INVARIANT_FAILURE, + "Unable to find exchange handle")); } } diff --git a/src/backenddb/merchantdb_plugin.c b/src/backenddb/merchantdb_plugin.c index d833a0c9..5d82243e 100644 --- a/src/backenddb/merchantdb_plugin.c +++ b/src/backenddb/merchantdb_plugin.c @@ -105,7 +105,7 @@ plugin_init () if (err > 0) { fprintf (stderr, - _("Initialization of plugin mechanism failed: %s!\n"), + _ ("Initialization of plugin mechanism failed: %s!\n"), lt_dlerror ()); return; } diff --git a/src/backenddb/plugin_merchantdb_postgres.c b/src/backenddb/plugin_merchantdb_postgres.c index 961bac26..fc5e2d1b 100644 --- a/src/backenddb/plugin_merchantdb_postgres.c +++ b/src/backenddb/plugin_merchantdb_postgres.c @@ -41,7 +41,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 @@ -50,7 +51,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) /** * Wrapper macro to add the currency from the plugin's state * when fetching amounts from the database. @@ -58,7 +61,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) /** @@ -73,11 +77,11 @@ struct PostgresClosure */ PGconn *conn; - /** + /** * Which currency do we deal in? */ char *currency; - + /** * Underlying configuration. */ @@ -102,19 +106,31 @@ postgres_drop_tables (void *cls) { struct PostgresClosure *pg = cls; struct GNUNET_PQ_ExecuteStatement es[] = { - GNUNET_PQ_make_try_execute ("DROP TABLE IF EXISTS merchant_transfers CASCADE;"), - GNUNET_PQ_make_try_execute ("DROP TABLE IF EXISTS merchant_deposits CASCADE;"), - GNUNET_PQ_make_try_execute ("DROP TABLE IF EXISTS merchant_transactions CASCADE;"), - GNUNET_PQ_make_try_execute ("DROP TABLE IF EXISTS merchant_proofs CASCADE;"), - GNUNET_PQ_make_try_execute ("DROP TABLE IF EXISTS merchant_contract_terms CASCADE;"), - GNUNET_PQ_make_try_execute ("DROP TABLE IF EXISTS merchant_refunds CASCADE;"), - GNUNET_PQ_make_try_execute ("DROP TABLE IF EXISTS exchange_wire_fees CASCADE;"), + GNUNET_PQ_make_try_execute ( + "DROP TABLE IF EXISTS merchant_transfers CASCADE;"), + GNUNET_PQ_make_try_execute ( + "DROP TABLE IF EXISTS merchant_deposits CASCADE;"), + GNUNET_PQ_make_try_execute ( + "DROP TABLE IF EXISTS merchant_transactions CASCADE;"), + GNUNET_PQ_make_try_execute ( + "DROP TABLE IF EXISTS merchant_proofs CASCADE;"), + GNUNET_PQ_make_try_execute ( + "DROP TABLE IF EXISTS merchant_contract_terms CASCADE;"), + GNUNET_PQ_make_try_execute ( + "DROP TABLE IF EXISTS merchant_refunds CASCADE;"), + GNUNET_PQ_make_try_execute ( + "DROP TABLE IF EXISTS exchange_wire_fees CASCADE;"), GNUNET_PQ_make_try_execute ("DROP TABLE IF EXISTS merchant_tips CASCADE;"), - GNUNET_PQ_make_try_execute ("DROP TABLE IF EXISTS merchant_tip_pickups CASCADE;"), - GNUNET_PQ_make_try_execute ("DROP TABLE IF EXISTS merchant_tip_reserve_credits CASCADE;"), - GNUNET_PQ_make_try_execute ("DROP TABLE IF EXISTS merchant_tip_reserves CASCADE;"), - GNUNET_PQ_make_try_execute ("DROP TABLE IF EXISTS merchant_orders CASCADE;"), - GNUNET_PQ_make_try_execute ("DROP TABLE IF EXISTS merchant_session_info CASCADE;"), + GNUNET_PQ_make_try_execute ( + "DROP TABLE IF EXISTS merchant_tip_pickups CASCADE;"), + GNUNET_PQ_make_try_execute ( + "DROP TABLE IF EXISTS merchant_tip_reserve_credits CASCADE;"), + GNUNET_PQ_make_try_execute ( + "DROP TABLE IF EXISTS merchant_tip_reserves CASCADE;"), + GNUNET_PQ_make_try_execute ( + "DROP TABLE IF EXISTS merchant_orders CASCADE;"), + GNUNET_PQ_make_try_execute ( + "DROP TABLE IF EXISTS merchant_session_info CASCADE;"), GNUNET_PQ_EXECUTE_STATEMENT_END }; @@ -145,17 +161,18 @@ postgres_initialize (void *cls) ",PRIMARY KEY (order_id, merchant_pub)" ");"), /* Offers we made to customers */ - GNUNET_PQ_make_execute ("CREATE TABLE IF NOT EXISTS merchant_contract_terms (" - "order_id VARCHAR NOT NULL" - ",merchant_pub BYTEA NOT NULL CHECK (LENGTH(merchant_pub)=32)" - ",contract_terms BYTEA NOT NULL" - ",h_contract_terms BYTEA NOT NULL CHECK (LENGTH(h_contract_terms)=64)" - ",timestamp INT8 NOT NULL" - ",row_id BIGSERIAL UNIQUE" - ",paid boolean DEFAULT FALSE NOT NULL" - ",PRIMARY KEY (order_id, merchant_pub)" - ",UNIQUE (h_contract_terms, merchant_pub)" - ");"), + GNUNET_PQ_make_execute ( + "CREATE TABLE IF NOT EXISTS merchant_contract_terms (" + "order_id VARCHAR NOT NULL" + ",merchant_pub BYTEA NOT NULL CHECK (LENGTH(merchant_pub)=32)" + ",contract_terms BYTEA NOT NULL" + ",h_contract_terms BYTEA NOT NULL CHECK (LENGTH(h_contract_terms)=64)" + ",timestamp INT8 NOT NULL" + ",row_id BIGSERIAL UNIQUE" + ",paid boolean DEFAULT FALSE NOT NULL" + ",PRIMARY KEY (order_id, merchant_pub)" + ",UNIQUE (h_contract_terms, merchant_pub)" + ");"), /* Table with the proofs for each coin we deposited at the exchange */ GNUNET_PQ_make_execute ("CREATE TABLE IF NOT EXISTS merchant_deposits (" " h_contract_terms BYTEA NOT NULL" @@ -192,10 +209,12 @@ postgres_initialize (void *cls) ",wtid BYTEA NOT NULL CHECK (LENGTH(wtid)=32)" ",PRIMARY KEY (h_contract_terms, coin_pub)" ");"), - GNUNET_PQ_make_try_execute ("CREATE INDEX IF NOT EXISTS merchant_transfers_by_coin" - " ON merchant_transfers (h_contract_terms, coin_pub)"), - GNUNET_PQ_make_try_execute ("CREATE INDEX IF NOT EXISTS merchant_transfers_by_wtid" - " ON merchant_transfers (wtid)"), + GNUNET_PQ_make_try_execute ( + "CREATE INDEX IF NOT EXISTS merchant_transfers_by_coin" + " ON merchant_transfers (h_contract_terms, coin_pub)"), + GNUNET_PQ_make_try_execute ( + "CREATE INDEX IF NOT EXISTS merchant_transfers_by_wtid" + " ON merchant_transfers (wtid)"), GNUNET_PQ_make_execute ("CREATE TABLE IF NOT EXISTS exchange_wire_fees (" " exchange_pub BYTEA NOT NULL CHECK (length(exchange_pub)=32)" ",h_wire_method BYTEA NOT NULL CHECK (length(h_wire_method)=64)" @@ -228,14 +247,15 @@ postgres_initialize (void *cls) ",PRIMARY KEY (reserve_priv)" ");"), /* table where we remember when tipping reserves where established / enabled */ - GNUNET_PQ_make_execute ("CREATE TABLE IF NOT EXISTS merchant_tip_reserve_credits (" - " reserve_priv BYTEA NOT NULL CHECK (LENGTH(reserve_priv)=32)" - ",credit_uuid BYTEA UNIQUE NOT NULL CHECK (LENGTH(credit_uuid)=64)" - ",timestamp INT8 NOT NULL" - ",amount_val INT8 NOT NULL" - ",amount_frac INT4 NOT NULL" - ",PRIMARY KEY (credit_uuid)" - ");"), + GNUNET_PQ_make_execute ( + "CREATE TABLE IF NOT EXISTS merchant_tip_reserve_credits (" + " reserve_priv BYTEA NOT NULL CHECK (LENGTH(reserve_priv)=32)" + ",credit_uuid BYTEA UNIQUE NOT NULL CHECK (LENGTH(credit_uuid)=64)" + ",timestamp INT8 NOT NULL" + ",amount_val INT8 NOT NULL" + ",amount_frac INT4 NOT NULL" + ",PRIMARY KEY (credit_uuid)" + ");"), /* tips that have been authorized */ GNUNET_PQ_make_execute ("CREATE TABLE IF NOT EXISTS merchant_tips (" " reserve_priv BYTEA NOT NULL CHECK (LENGTH(reserve_priv)=32)" @@ -739,7 +759,7 @@ check_connection (struct PostgresClosure *pg) "merchantdb-postgres"); GNUNET_break (NULL != pg->conn); GNUNET_break (GNUNET_OK == - postgres_initialize (pg)); + postgres_initialize (pg)); } @@ -875,8 +895,10 @@ postgres_commit (void *cls) static enum GNUNET_DB_QueryStatus postgres_find_contract_terms_from_hash (void *cls, json_t **contract_terms, - const struct GNUNET_HashCode *h_contract_terms, - const struct TALER_MerchantPublicKeyP *merchant_pub) + const struct + GNUNET_HashCode *h_contract_terms, + const struct + TALER_MerchantPublicKeyP *merchant_pub) { struct PostgresClosure *pg = cls; struct GNUNET_PQ_QueryParam params[] = { @@ -910,8 +932,11 @@ postgres_find_contract_terms_from_hash (void *cls, static enum GNUNET_DB_QueryStatus postgres_find_paid_contract_terms_from_hash (void *cls, json_t **contract_terms, - const struct GNUNET_HashCode *h_contract_terms, - const struct TALER_MerchantPublicKeyP *merchant_pub) + const struct + GNUNET_HashCode *h_contract_terms, + const struct + TALER_MerchantPublicKeyP * + merchant_pub) { struct PostgresClosure *pg = cls; struct GNUNET_PQ_QueryParam params[] = { @@ -948,7 +973,8 @@ static enum GNUNET_DB_QueryStatus postgres_find_contract_terms (void *cls, json_t **contract_terms, const char *order_id, - const struct TALER_MerchantPublicKeyP *merchant_pub) + const struct + TALER_MerchantPublicKeyP *merchant_pub) { struct PostgresClosure *pg = cls; struct GNUNET_PQ_QueryParam params[] = { @@ -1027,10 +1053,11 @@ postgres_find_order (void *cls, */ static enum GNUNET_DB_QueryStatus postgres_insert_contract_terms (void *cls, - const char *order_id, - const struct TALER_MerchantPublicKeyP *merchant_pub, - struct GNUNET_TIME_Absolute timestamp, - const json_t *contract_terms) + const char *order_id, + const struct + TALER_MerchantPublicKeyP *merchant_pub, + struct GNUNET_TIME_Absolute timestamp, + const json_t *contract_terms) { struct PostgresClosure *pg = cls; struct GNUNET_HashCode h_contract_terms; @@ -1045,7 +1072,7 @@ postgres_insert_contract_terms (void *cls, if (GNUNET_OK != TALER_JSON_hash (contract_terms, - &h_contract_terms)) + &h_contract_terms)) { GNUNET_break (0); return GNUNET_SYSERR; @@ -1117,7 +1144,8 @@ postgres_insert_order (void *cls, static enum GNUNET_DB_QueryStatus postgres_mark_proposal_paid (void *cls, const struct GNUNET_HashCode *h_contract_terms, - const struct TALER_MerchantPublicKeyP *merchant_pub) + const struct + TALER_MerchantPublicKeyP *merchant_pub) { struct PostgresClosure *pg = cls; struct GNUNET_PQ_QueryParam params[] = { @@ -1152,7 +1180,8 @@ postgres_insert_session_info (void *cls, const char *session_id, const char *fulfillment_url, const char *order_id, - const struct TALER_MerchantPublicKeyP *merchant_pub) + const struct + TALER_MerchantPublicKeyP *merchant_pub) { struct PostgresClosure *pg = cls; @@ -1202,7 +1231,7 @@ postgres_find_session_info (void *cls, GNUNET_PQ_result_spec_string ("order_id", order_id), GNUNET_PQ_result_spec_end - }; + }; // We don't clean up the result spec since we want // to keep around the memory for order_id. return GNUNET_PQ_eval_prepared_singleton_select (pg->conn, @@ -1284,8 +1313,10 @@ postgres_store_deposit (void *cls, static enum GNUNET_DB_QueryStatus postgres_store_coin_to_transfer (void *cls, const struct GNUNET_HashCode *h_contract_terms, - const struct TALER_CoinSpendPublicKeyP *coin_pub, - const struct TALER_WireTransferIdentifierRawP *wtid) + const struct + TALER_CoinSpendPublicKeyP *coin_pub, + const struct + TALER_WireTransferIdentifierRawP *wtid) { struct PostgresClosure *pg = cls; struct GNUNET_PQ_QueryParam params[] = { @@ -1316,9 +1347,11 @@ postgres_store_coin_to_transfer (void *cls, static enum GNUNET_DB_QueryStatus postgres_store_transfer_to_proof (void *cls, const char *exchange_url, - const struct TALER_WireTransferIdentifierRawP *wtid, + const struct + TALER_WireTransferIdentifierRawP *wtid, struct GNUNET_TIME_Absolute execution_time, - const struct TALER_ExchangePublicKeyP *signkey_pub, + const struct + TALER_ExchangePublicKeyP *signkey_pub, const json_t *exchange_proof) { struct PostgresClosure *pg = cls; @@ -1352,7 +1385,8 @@ postgres_store_transfer_to_proof (void *cls, static enum GNUNET_DB_QueryStatus postgres_find_contract_terms_history (void *cls, const char *order_id, - const struct TALER_MerchantPublicKeyP *merchant_pub, + const struct + TALER_MerchantPublicKeyP *merchant_pub, TALER_MERCHANTDB_ProposalDataCallback cb, void *cb_cls) { @@ -1485,13 +1519,17 @@ find_contracts_cb (void *cls, */ static enum GNUNET_DB_QueryStatus postgres_find_contract_terms_by_date_and_range (void *cls, - struct GNUNET_TIME_Absolute date, - const struct TALER_MerchantPublicKeyP *merchant_pub, + struct GNUNET_TIME_Absolute + date, + const struct + TALER_MerchantPublicKeyP * + merchant_pub, uint64_t start, uint64_t nrows, int past, unsigned int ascending, - TALER_MERCHANTDB_ProposalDataCallback cb, + TALER_MERCHANTDB_ProposalDataCallback + cb, void *cb_cls) { struct PostgresClosure *pg = cls; @@ -1516,10 +1554,10 @@ postgres_find_contract_terms_by_date_and_range (void *cls, (GNUNET_YES == past) ? ( (GNUNET_YES == ascending) ? "find_contract_terms_by_date_and_range_past_asc" - : "find_contract_terms_by_date_and_range_past" ) + : "find_contract_terms_by_date_and_range_past") : ( (GNUNET_YES == ascending) ? "find_contract_terms_by_date_and_range_asc" - : "find_contract_terms_by_date_and_range" ); + : "find_contract_terms_by_date_and_range"); check_connection (pg); qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn, stmt, @@ -1584,7 +1622,7 @@ find_tip_authorizations_cb (void *cls, GNUNET_PQ_result_spec_auto_from_type ("tip_id", &h), TALER_PQ_RESULT_SPEC_AMOUNT ("amount", - &amount), + &amount), TALER_PQ_result_spec_json ("extra", &extra), GNUNET_PQ_result_spec_end @@ -1645,7 +1683,8 @@ find_tip_authorizations_cb (void *cls, */ static enum GNUNET_DB_QueryStatus postgres_get_authorized_tip_amount (void *cls, - const struct TALER_ReservePrivateKeyP *reserve_priv, + const struct + TALER_ReservePrivateKeyP *reserve_priv, struct TALER_Amount *authorized_amount) { struct PostgresClosure *pg = cls; @@ -1687,7 +1726,8 @@ postgres_get_authorized_tip_amount (void *cls, static enum GNUNET_DB_QueryStatus postgres_find_contract_terms_by_date (void *cls, struct GNUNET_TIME_Absolute date, - const struct TALER_MerchantPublicKeyP *merchant_pub, + const struct + TALER_MerchantPublicKeyP *merchant_pub, uint64_t nrows, TALER_MERCHANTDB_ProposalDataCallback cb, void *cb_cls) @@ -1765,7 +1805,7 @@ find_payments_cb (void *cls, struct FindPaymentsContext *fpc = cls; struct PostgresClosure *pg = fpc->pg; - for (unsigned int i=0;i<num_results;i++) + for (unsigned int i = 0; i<num_results; i++) { struct TALER_CoinSpendPublicKeyP coin_pub; struct TALER_Amount amount_with_fee; @@ -1884,7 +1924,7 @@ struct FindPaymentsByCoinContext * Plugin context. */ struct PostgresClosure *pg; - + /** * Coin we are looking for. */ @@ -1917,8 +1957,8 @@ find_payments_by_coin_cb (void *cls, { struct FindPaymentsByCoinContext *fpc = cls; struct PostgresClosure *pg = fpc->pg; - - for (unsigned int i=0;i<num_results;i++) + + for (unsigned int i = 0; i<num_results; i++) { struct TALER_Amount amount_with_fee; struct TALER_Amount deposit_fee; @@ -1936,7 +1976,7 @@ find_payments_by_coin_cb (void *cls, TALER_PQ_RESULT_SPEC_AMOUNT ("wire_fee", &wire_fee), GNUNET_PQ_result_spec_string ("exchange_url", - &exchange_url), + &exchange_url), TALER_PQ_result_spec_json ("exchange_proof", &exchange_proof), GNUNET_PQ_result_spec_end @@ -1979,9 +2019,12 @@ find_payments_by_coin_cb (void *cls, */ static enum GNUNET_DB_QueryStatus postgres_find_payments_by_hash_and_coin (void *cls, - const struct GNUNET_HashCode *h_contract_terms, - const struct TALER_MerchantPublicKeyP *merchant_pub, - const struct TALER_CoinSpendPublicKeyP *coin_pub, + const struct + GNUNET_HashCode *h_contract_terms, + const struct + TALER_MerchantPublicKeyP *merchant_pub, + const struct + TALER_CoinSpendPublicKeyP *coin_pub, TALER_MERCHANTDB_CoinDepositCallback cb, void *cb_cls) { @@ -2054,8 +2097,8 @@ find_transfers_cb (void *cls, unsigned int num_results) { struct FindTransfersContext *ftc = cls; - - for (unsigned int i=0;i<PQntuples (result);i++) + + for (unsigned int i = 0; i<PQntuples (result); i++) { struct TALER_CoinSpendPublicKeyP coin_pub; struct TALER_WireTransferIdentifierRawP wtid; @@ -2158,7 +2201,7 @@ struct FindDepositsContext * Plugin context. */ struct PostgresClosure *pg; - + /** * Transaction status (set). */ @@ -2182,7 +2225,7 @@ find_deposits_cb (void *cls, struct FindDepositsContext *fdc = cls; struct PostgresClosure *pg = fdc->pg; - for (unsigned int i=0;i<PQntuples (result);i++) + for (unsigned int i = 0; i<PQntuples (result); i++) { struct GNUNET_HashCode h_contract_terms; struct TALER_CoinSpendPublicKeyP coin_pub; @@ -2206,7 +2249,7 @@ find_deposits_cb (void *cls, TALER_PQ_RESULT_SPEC_AMOUNT ("wire_fee", &wire_fee), GNUNET_PQ_result_spec_string ("exchange_url", - &exchange_url), + &exchange_url), TALER_PQ_result_spec_json ("exchange_proof", &exchange_proof), GNUNET_PQ_result_spec_end @@ -2247,7 +2290,8 @@ find_deposits_cb (void *cls, */ static enum GNUNET_DB_QueryStatus postgres_find_deposits_by_wtid (void *cls, - const struct TALER_WireTransferIdentifierRawP *wtid, + const struct + TALER_WireTransferIdentifierRawP *wtid, TALER_MERCHANTDB_CoinDepositCallback cb, void *cb_cls) { @@ -2318,7 +2362,7 @@ get_refunds_cb (void *cls, struct GetRefundsContext *grc = cls; struct PostgresClosure *pg = grc->pg; - for (unsigned int i=0;i<num_results;i++) + for (unsigned int i = 0; i<num_results; i++) { struct TALER_CoinSpendPublicKeyP coin_pub; uint64_t rtransaction_id; @@ -2372,9 +2416,13 @@ get_refunds_cb (void *cls, */ static enum GNUNET_DB_QueryStatus postgres_get_refunds_from_contract_terms_hash (void *cls, - const struct TALER_MerchantPublicKeyP *merchant_pub, - const struct GNUNET_HashCode *h_contract_terms, - TALER_MERCHANTDB_RefundCallback rc, + const struct + TALER_MerchantPublicKeyP * + merchant_pub, + const struct + GNUNET_HashCode *h_contract_terms, + TALER_MERCHANTDB_RefundCallback + rc, void *rc_cls) { struct PostgresClosure *pg = cls; @@ -2466,13 +2514,16 @@ insert_refund (void *cls, */ static enum GNUNET_DB_QueryStatus postgres_store_wire_fee_by_exchange (void *cls, - const struct TALER_MasterPublicKeyP *exchange_pub, - const struct GNUNET_HashCode *h_wire_method, + const struct + TALER_MasterPublicKeyP *exchange_pub, + const struct + GNUNET_HashCode *h_wire_method, const struct TALER_Amount *wire_fee, const struct TALER_Amount *closing_fee, struct GNUNET_TIME_Absolute start_date, struct GNUNET_TIME_Absolute end_date, - const struct TALER_MasterSignatureP *exchange_sig) + const struct + TALER_MasterSignatureP *exchange_sig) { struct PostgresClosure *pg = cls; struct GNUNET_PQ_QueryParam params[] = { @@ -2565,7 +2616,7 @@ struct FindRefundContext * Plugin context. */ struct PostgresClosure *pg; - + /** * Updated to reflect total amount refunded so far. */ @@ -2593,8 +2644,8 @@ process_refund_cb (void *cls, { struct FindRefundContext *ictx = cls; struct PostgresClosure *pg = ictx->pg; - - for (unsigned int i=0; i<num_results; i++) + + for (unsigned int i = 0; i<num_results; i++) { /* Sum up existing refunds */ struct TALER_Amount acc; @@ -2682,10 +2733,10 @@ process_deposits_for_refund_cb (void *cls, struct InsertRefundContext *ctx = cls; struct PostgresClosure *pg = ctx->pg; struct TALER_Amount current_refund; - struct TALER_Amount deposit_refund[GNUNET_NZL(num_results)]; - struct TALER_CoinSpendPublicKeyP deposit_coin_pubs[GNUNET_NZL(num_results)]; - struct TALER_Amount deposit_amount_with_fee[GNUNET_NZL(num_results)]; - struct TALER_Amount deposit_refund_fee[GNUNET_NZL(num_results)]; + struct TALER_Amount deposit_refund[GNUNET_NZL (num_results)]; + struct TALER_CoinSpendPublicKeyP deposit_coin_pubs[GNUNET_NZL (num_results)]; + struct TALER_Amount deposit_amount_with_fee[GNUNET_NZL (num_results)]; + struct TALER_Amount deposit_refund_fee[GNUNET_NZL (num_results)]; GNUNET_assert (GNUNET_OK == TALER_amount_get_zero (ctx->refund->currency, @@ -2693,7 +2744,7 @@ process_deposits_for_refund_cb (void *cls, /* Pass 1: Collect amount of existing refunds into current_refund. * Also store existing refunded amount for each deposit in deposit_refund. */ - for (unsigned int i=0; i<num_results; i++) + for (unsigned int i = 0; i<num_results; i++) { struct TALER_CoinSpendPublicKeyP coin_pub; struct TALER_Amount amount_with_fee; @@ -2779,7 +2830,7 @@ process_deposits_for_refund_cb (void *cls, } /* Phase 2: Try to increase current refund until it matches desired refund */ - for (unsigned int i=0;i<num_results; i++) + for (unsigned int i = 0; i<num_results; i++) { const struct TALER_Amount *increment; struct TALER_Amount left; @@ -2906,8 +2957,10 @@ process_deposits_for_refund_cb (void *cls, */ static enum GNUNET_DB_QueryStatus postgres_increase_refund_for_contract_NT (void *cls, - const struct GNUNET_HashCode *h_contract_terms, - const struct TALER_MerchantPublicKeyP *merchant_pub, + const struct + GNUNET_HashCode *h_contract_terms, + const struct + TALER_MerchantPublicKeyP *merchant_pub, const struct TALER_Amount *refund, const char *reason) { @@ -2966,7 +3019,8 @@ postgres_increase_refund_for_contract_NT (void *cls, static enum GNUNET_DB_QueryStatus postgres_find_proof_by_wtid (void *cls, const char *exchange_url, - const struct TALER_WireTransferIdentifierRawP *wtid, + const struct + TALER_WireTransferIdentifierRawP *wtid, TALER_MERCHANTDB_ProofCallback cb, void *cb_cls) { @@ -3017,7 +3071,8 @@ postgres_find_proof_by_wtid (void *cls, */ static enum GNUNET_DB_QueryStatus postgres_enable_tip_reserve_TR (void *cls, - const struct TALER_ReservePrivateKeyP *reserve_priv, + const struct + TALER_ReservePrivateKeyP *reserve_priv, const struct GNUNET_HashCode *credit_uuid, const struct TALER_Amount *credit, struct GNUNET_TIME_Absolute expiration) @@ -3032,7 +3087,7 @@ postgres_enable_tip_reserve_TR (void *cls, retries = 0; check_connection (pg); - RETRY: +RETRY: if (MAX_RETRIES < ++retries) return GNUNET_DB_STATUS_SOFT_ERROR; if (GNUNET_OK != @@ -3164,8 +3219,8 @@ postgres_enable_tip_reserve_TR (void *cls, const char *stmt; stmt = (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qs) - ? "update_tip_reserve_balance" - : "insert_tip_reserve_balance"; + ? "update_tip_reserve_balance" + : "insert_tip_reserve_balance"; qs = GNUNET_PQ_eval_prepared_non_select (pg->conn, stmt, params); @@ -3239,7 +3294,7 @@ postgres_authorize_tip_TR (void *cls, retries = 0; check_connection (pg); - RETRY: +RETRY: if (MAX_RETRIES < ++retries) return TALER_EC_TIP_AUTHORIZE_DB_SOFT_ERROR; if (GNUNET_OK != @@ -3250,9 +3305,9 @@ postgres_authorize_tip_TR (void *cls, return TALER_EC_TIP_AUTHORIZE_DB_HARD_ERROR; } qs = GNUNET_PQ_eval_prepared_singleton_select (pg->conn, - "lookup_tip_reserve_balance", - params, - rs); + "lookup_tip_reserve_balance", + params, + rs); if (0 >= qs) { /* reserve unknown */ @@ -3378,9 +3433,9 @@ postgres_lookup_tip_by_id (void *cls, TALER_PQ_result_spec_json ("extra", &res_extra), TALER_PQ_RESULT_SPEC_AMOUNT ("amount", - &res_amount), + &res_amount), TALER_PQ_RESULT_SPEC_AMOUNT ("left", - &res_amount_left), + &res_amount_left), GNUNET_PQ_result_spec_end }; enum GNUNET_DB_QueryStatus qs; @@ -3455,7 +3510,7 @@ postgres_pickup_tip_TR (void *cls, retries = 0; check_connection (pg); - RETRY: +RETRY: if (MAX_RETRIES < ++retries) return TALER_EC_TIP_PICKUP_DB_ERROR_SOFT; if (GNUNET_OK != @@ -3665,7 +3720,8 @@ libtaler_plugin_merchantdb_postgres_init (void *cls) plugin->store_coin_to_transfer = &postgres_store_coin_to_transfer; plugin->store_transfer_to_proof = &postgres_store_transfer_to_proof; plugin->store_wire_fee_by_exchange = &postgres_store_wire_fee_by_exchange; - plugin->find_payments_by_hash_and_coin = &postgres_find_payments_by_hash_and_coin; + plugin->find_payments_by_hash_and_coin = + &postgres_find_payments_by_hash_and_coin; plugin->find_payments = &postgres_find_payments; plugin->find_transfers_by_hash = &postgres_find_transfers_by_hash; plugin->find_deposits_by_wtid = &postgres_find_deposits_by_wtid; @@ -3677,12 +3733,17 @@ libtaler_plugin_merchantdb_postgres_init (void *cls) plugin->find_contract_terms_history = &postgres_find_contract_terms_history; plugin->find_contract_terms_by_date = &postgres_find_contract_terms_by_date; plugin->get_authorized_tip_amount = &postgres_get_authorized_tip_amount; - plugin->find_contract_terms_by_date_and_range = &postgres_find_contract_terms_by_date_and_range; - plugin->find_contract_terms_from_hash = &postgres_find_contract_terms_from_hash; - plugin->find_paid_contract_terms_from_hash = &postgres_find_paid_contract_terms_from_hash; - plugin->get_refunds_from_contract_terms_hash = &postgres_get_refunds_from_contract_terms_hash; + plugin->find_contract_terms_by_date_and_range = + &postgres_find_contract_terms_by_date_and_range; + plugin->find_contract_terms_from_hash = + &postgres_find_contract_terms_from_hash; + plugin->find_paid_contract_terms_from_hash = + &postgres_find_paid_contract_terms_from_hash; + plugin->get_refunds_from_contract_terms_hash = + &postgres_get_refunds_from_contract_terms_hash; plugin->lookup_wire_fee = &postgres_lookup_wire_fee; - plugin->increase_refund_for_contract_NT = &postgres_increase_refund_for_contract_NT; + plugin->increase_refund_for_contract_NT = + &postgres_increase_refund_for_contract_NT; plugin->mark_proposal_paid = &postgres_mark_proposal_paid; plugin->insert_session_info = &postgres_insert_session_info; plugin->find_session_info = &postgres_find_session_info; diff --git a/src/backenddb/test_merchantdb.c b/src/backenddb/test_merchantdb.c index 84a100c3..5756bbb1 100644 --- a/src/backenddb/test_merchantdb.c +++ b/src/backenddb/test_merchantdb.c @@ -29,7 +29,7 @@ #define FAILIF(cond) \ do { \ - if (!(cond)){ break;} \ + if (! (cond)) { break;} \ GNUNET_break (0); \ goto drop; \ } while (0) @@ -206,14 +206,14 @@ static json_t *contract_terms_future; */ static void refund_cb (void *cls, - const struct TALER_CoinSpendPublicKeyP *coin_pub, - uint64_t rtransaction_id, - const char *reason, - const struct TALER_Amount *refund_amount, - const struct TALER_Amount *refund_fee) + const struct TALER_CoinSpendPublicKeyP *coin_pub, + uint64_t rtransaction_id, + const char *reason, + const struct TALER_Amount *refund_amount, + const struct TALER_Amount *refund_fee) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "refund_cb\n"); + "refund_cb\n"); /* FIXME, more logic here? */ } @@ -363,9 +363,9 @@ test_wire_fee () date1 = GNUNET_TIME_absolute_get (); (void) GNUNET_TIME_round_abs (&date1); date2 = GNUNET_TIME_absolute_add (date1, - GNUNET_TIME_UNIT_DAYS); + GNUNET_TIME_UNIT_DAYS); date3 = GNUNET_TIME_absolute_add (date2, - GNUNET_TIME_UNIT_DAYS); + GNUNET_TIME_UNIT_DAYS); GNUNET_assert (GNUNET_OK == TALER_string_to_amount (CURRENCY ":5", &closing_fee1)); @@ -380,26 +380,26 @@ test_wire_fee () &wire_fee2)); if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != plugin->store_wire_fee_by_exchange (plugin->cls, - &exchange_pub, - &h_wire_method, - &wire_fee1, - &closing_fee1, - date1, - date2, - &exchange_sig)) + &exchange_pub, + &h_wire_method, + &wire_fee1, + &closing_fee1, + date1, + date2, + &exchange_sig)) { GNUNET_break (0); return GNUNET_SYSERR; } if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != plugin->store_wire_fee_by_exchange (plugin->cls, - &exchange_pub, - &h_wire_method, - &wire_fee2, - &closing_fee2, - date2, - date3, - &exchange_sig)) + &exchange_pub, + &h_wire_method, + &wire_fee2, + &closing_fee2, + date2, + date3, + &exchange_sig)) { GNUNET_break (0); return GNUNET_SYSERR; @@ -407,14 +407,14 @@ test_wire_fee () contract_date = date2; /* test inclusive/exclusive range */ if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != plugin->lookup_wire_fee (plugin->cls, - &exchange_pub, - &h_wire_method, - contract_date, - &wire_fee3, - &closing_fee3, - &start_date, - &end_date, - &exchange_sig2)) + &exchange_pub, + &h_wire_method, + contract_date, + &wire_fee3, + &closing_fee3, + &start_date, + &end_date, + &exchange_sig2)) { GNUNET_break (0); return GNUNET_SYSERR; @@ -424,25 +424,25 @@ test_wire_fee () (0 != GNUNET_memcmp (&exchange_sig, &exchange_sig2)) || (0 != TALER_amount_cmp (&wire_fee2, - &wire_fee3)) || + &wire_fee3)) || (0 != TALER_amount_cmp (&closing_fee2, - &closing_fee3)) ) + &closing_fee3)) ) { GNUNET_break (0); return GNUNET_SYSERR; } contract_date = GNUNET_TIME_absolute_add (date1, - GNUNET_TIME_UNIT_SECONDS); + GNUNET_TIME_UNIT_SECONDS); if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != plugin->lookup_wire_fee (plugin->cls, - &exchange_pub, - &h_wire_method, - contract_date, - &wire_fee3, - &closing_fee3, - &start_date, - &end_date, - &exchange_sig2)) + &exchange_pub, + &h_wire_method, + contract_date, + &wire_fee3, + &closing_fee3, + &start_date, + &end_date, + &exchange_sig2)) { GNUNET_break (0); return GNUNET_SYSERR; @@ -452,9 +452,9 @@ test_wire_fee () (0 != GNUNET_memcmp (&exchange_sig, &exchange_sig2)) || (0 != TALER_amount_cmp (&wire_fee1, - &wire_fee3)) || + &wire_fee3)) || (0 != TALER_amount_cmp (&closing_fee1, - &closing_fee3)) ) + &closing_fee3)) ) { GNUNET_break (0); return GNUNET_SYSERR; @@ -462,14 +462,14 @@ test_wire_fee () contract_date = date3; /* outside of valid range! */ if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS != plugin->lookup_wire_fee (plugin->cls, - &exchange_pub, - &h_wire_method, - contract_date, - &wire_fee3, - &closing_fee3, - &start_date, - &end_date, - &exchange_sig2)) + &exchange_pub, + &h_wire_method, + contract_date, + &wire_fee3, + &closing_fee3, + &start_date, + &end_date, + &exchange_sig2)) { GNUNET_break (0); return GNUNET_SYSERR; @@ -518,8 +518,9 @@ test_tipping () &total)); /* Pick short expiration, but long enough to run 2 DB interactions even on very slow systems. */ - reserve_expiration = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, - 2)); + reserve_expiration = GNUNET_TIME_relative_to_absolute ( + GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, + 2)); if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != plugin->enable_tip_reserve_TR (plugin->cls, &tip_reserve_priv, @@ -559,8 +560,9 @@ test_tipping () /* Re-add some funds again */ RND_BLK (&tip_credit_uuid); - reserve_expiration = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, - 2)); + reserve_expiration = GNUNET_TIME_relative_to_absolute ( + GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, + 2)); if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != plugin->enable_tip_reserve_TR (plugin->cls, &tip_reserve_priv, @@ -610,15 +612,15 @@ test_tipping () } if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != plugin->lookup_tip_by_id (plugin->cls, - &tip_id, - &url, - NULL, NULL, NULL, NULL)) + &tip_id, + &url, + NULL, NULL, NULL, NULL)) { GNUNET_break (0); return GNUNET_SYSERR; } if (0 != strcmp ("http://localhost:8081/", - url)) + url)) { GNUNET_free (url); GNUNET_break (0); @@ -773,7 +775,7 @@ run (void *cls) (void) GNUNET_TIME_round_abs (×tamp); delta = GNUNET_TIME_UNIT_MINUTES; fake_now = GNUNET_TIME_absolute_add (timestamp, delta); - refund_deadline = GNUNET_TIME_absolute_get(); + refund_deadline = GNUNET_TIME_absolute_get (); (void) GNUNET_TIME_round_abs (&refund_deadline); GNUNET_assert (GNUNET_OK == TALER_string_to_amount (CURRENCY ":5", @@ -829,10 +831,10 @@ run (void *cls) FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != plugin->insert_contract_terms (plugin->cls, - order_id, - &merchant_pub, - timestamp, - contract_terms)); + order_id, + &merchant_pub, + timestamp, + contract_terms)); FAILIF (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS != plugin->find_paid_contract_terms_from_hash (plugin->cls, @@ -852,11 +854,11 @@ run (void *cls) FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != - plugin->find_contract_terms_history (plugin->cls, - order_id, - &merchant_pub, - &pd_cb, - NULL)); + plugin->find_contract_terms_history (plugin->cls, + order_id, + &merchant_pub, + &pd_cb, + NULL)); FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != plugin->find_paid_contract_terms_from_hash (plugin->cls, @@ -865,28 +867,28 @@ run (void *cls) &merchant_pub)); FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != plugin->find_contract_terms_from_hash (plugin->cls, - &out, - &h_contract_terms, - &merchant_pub)); + &out, + &h_contract_terms, + &merchant_pub)); FAILIF (1 != plugin->find_contract_terms_by_date_and_range (plugin->cls, - fake_now, - &merchant_pub, - 2, - 1, - GNUNET_YES, - GNUNET_NO, - &pd_cb, - NULL)); + fake_now, + &merchant_pub, + 2, + 1, + GNUNET_YES, + GNUNET_NO, + &pd_cb, + NULL)); timestamp = GNUNET_TIME_absolute_get (); (void) GNUNET_TIME_round_abs (×tamp); FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != plugin->insert_contract_terms (plugin->cls, - order_id_future, - &merchant_pub, - timestamp, - contract_terms_future)); + order_id_future, + &merchant_pub, + timestamp, + contract_terms_future)); fake_now = GNUNET_TIME_absolute_subtract (timestamp, delta); @@ -900,33 +902,33 @@ run (void *cls) &merchant_pub)); FAILIF (2 != plugin->find_contract_terms_by_date_and_range (plugin->cls, - fake_now, - &merchant_pub, - 0, - 5, - GNUNET_NO, - GNUNET_NO, - &pd_cb, - NULL)); + fake_now, + &merchant_pub, + 0, + 5, + GNUNET_NO, + GNUNET_NO, + &pd_cb, + NULL)); FAILIF (0 != plugin->find_contract_terms_by_date (plugin->cls, - fake_now, - &merchant_pub, - 1, - &pd_cb, - NULL)); + fake_now, + &merchant_pub, + 1, + &pd_cb, + NULL)); FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != plugin->store_deposit (plugin->cls, &h_contract_terms, - &merchant_pub, + &merchant_pub, &coin_pub, - EXCHANGE_URL, + EXCHANGE_URL, &amount_with_fee, &deposit_fee, &refund_fee, - &wire_fee, + &wire_fee, &signkey_pub, deposit_proof)); FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != @@ -1008,17 +1010,17 @@ run (void *cls) " to too big refund amount")); FAILIF (GNUNET_OK != - test_wire_fee ()); + test_wire_fee ()); FAILIF (GNUNET_OK != - test_tipping ()); + test_tipping ()); if (-1 == result) result = 0; - drop: +drop: GNUNET_break (GNUNET_OK == - plugin->drop_tables (plugin->cls)); + plugin->drop_tables (plugin->cls)); TALER_MERCHANTDB_plugin_unload (plugin); plugin = NULL; if (NULL != deposit_proof) diff --git a/src/include/platform.h b/src/include/platform.h index a2ed6f4c..a2765145 100644 --- a/src/include/platform.h +++ b/src/include/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_merchant_service.h b/src/include/taler_merchant_service.h index f219be61..cefafccf 100644 --- a/src/include/taler_merchant_service.h +++ b/src/include/taler_merchant_service.h @@ -48,9 +48,9 @@ struct TALER_MERCHANT_RefundLookupOperation; */ typedef void (*TALER_MERCHANT_RefundLookupCallback) (void *cls, - unsigned int http_status, - enum TALER_ErrorCode ec, - const json_t *obj); + unsigned int http_status, + enum TALER_ErrorCode ec, + const json_t *obj); /** * Does a GET /refund. @@ -75,7 +75,8 @@ TALER_MERCHANT_refund_lookup (struct GNUNET_CURL_Context *ctx, * @param rlo the refund increasing operation to cancel */ void -TALER_MERCHANT_refund_lookup_cancel (struct TALER_MERCHANT_RefundLookupOperation *rlo); +TALER_MERCHANT_refund_lookup_cancel (struct + TALER_MERCHANT_RefundLookupOperation *rlo); /** @@ -125,7 +126,9 @@ TALER_MERCHANT_refund_increase (struct GNUNET_CURL_Context *ctx, * @param rio the refund increasing operation to cancel */ void -TALER_MERCHANT_refund_increase_cancel (struct TALER_MERCHANT_RefundIncreaseOperation *rio); +TALER_MERCHANT_refund_increase_cancel (struct + TALER_MERCHANT_RefundIncreaseOperation * + rio); /* ********************* /proposal *********************** */ @@ -150,7 +153,7 @@ struct TALER_MERCHANT_ProposalOperation; typedef void (*TALER_MERCHANT_ProposalCallback) (void *cls, unsigned int http_status, - enum TALER_ErrorCode ec, + enum TALER_ErrorCode ec, const json_t *obj, const char *order_id); @@ -203,8 +206,10 @@ typedef void unsigned int http_status, const json_t *body, const json_t *contract_terms, - const struct TALER_MerchantSignatureP *sig, - const struct GNUNET_HashCode *hash); + const struct + TALER_MerchantSignatureP *sig, + const struct + GNUNET_HashCode *hash); /** @@ -224,8 +229,10 @@ struct TALER_MERCHANT_ProposalLookupOperation * TALER_MERCHANT_proposal_lookup (struct GNUNET_CURL_Context *ctx, const char *backend_url, const char *order_id, - const struct GNUNET_CRYPTO_EddsaPublicKey *nonce, - TALER_MERCHANT_ProposalLookupOperationCallback plo_cb, + const struct + GNUNET_CRYPTO_EddsaPublicKey *nonce, + TALER_MERCHANT_ProposalLookupOperationCallback + plo_cb, void *plo_cb_cls); @@ -235,7 +242,9 @@ TALER_MERCHANT_proposal_lookup (struct GNUNET_CURL_Context *ctx, * @param plo handle to the request to be canceled */ void -TALER_MERCHANT_proposal_lookup_cancel (struct TALER_MERCHANT_ProposalLookupOperation *plo); +TALER_MERCHANT_proposal_lookup_cancel (struct + TALER_MERCHANT_ProposalLookupOperation * + plo); @@ -269,7 +278,7 @@ struct TALER_MERCHANT_Pay; typedef void (*TALER_MERCHANT_PayCallback) (void *cls, unsigned int http_status, - enum TALER_ErrorCode ec, + enum TALER_ErrorCode ec, const json_t *obj); @@ -346,7 +355,7 @@ struct TALER_MERCHANT_PayCoin */ struct TALER_MERCHANT_Pay * TALER_MERCHANT_pay_wallet (struct GNUNET_CURL_Context *ctx, - const char *merchant_url, + const char *merchant_url, const struct GNUNET_HashCode *h_contract, const struct TALER_Amount *amount, const struct TALER_Amount *max_fee, @@ -403,13 +412,15 @@ struct TALER_MERCHANT_RefundEntry */ typedef void (*TALER_MERCHANT_PayRefundCallback) (void *cls, - unsigned int http_status, - enum TALER_ErrorCode ec, - const struct TALER_MerchantPublicKeyP *merchant_pub, - const struct GNUNET_HashCode *h_contract, - unsigned int num_refunds, - const struct TALER_MERCHANT_RefundEntry *res, - const json_t *obj); + unsigned int http_status, + enum TALER_ErrorCode ec, + const struct + TALER_MerchantPublicKeyP *merchant_pub, + const struct GNUNET_HashCode *h_contract, + unsigned int num_refunds, + const struct + TALER_MERCHANT_RefundEntry *res, + const json_t *obj); /** @@ -437,21 +448,21 @@ typedef void */ struct TALER_MERCHANT_Pay * TALER_MERCHANT_pay_abort (struct GNUNET_CURL_Context *ctx, - const char *merchant_url, - const struct GNUNET_HashCode *h_contract, - const struct TALER_Amount *amount, - const struct TALER_Amount *max_fee, - const struct TALER_MerchantPublicKeyP *merchant_pub, - const struct TALER_MerchantSignatureP *merchant_sig, - struct GNUNET_TIME_Absolute timestamp, - struct GNUNET_TIME_Absolute refund_deadline, - struct GNUNET_TIME_Absolute pay_deadline, - const struct GNUNET_HashCode *h_wire, - const char *order_id, - unsigned int num_coins, - const struct TALER_MERCHANT_PayCoin *coins, - TALER_MERCHANT_PayRefundCallback payref_cb, - void *payref_cb_cls); + const char *merchant_url, + const struct GNUNET_HashCode *h_contract, + const struct TALER_Amount *amount, + const struct TALER_Amount *max_fee, + const struct TALER_MerchantPublicKeyP *merchant_pub, + const struct TALER_MerchantSignatureP *merchant_sig, + struct GNUNET_TIME_Absolute timestamp, + struct GNUNET_TIME_Absolute refund_deadline, + struct GNUNET_TIME_Absolute pay_deadline, + const struct GNUNET_HashCode *h_wire, + const char *order_id, + unsigned int num_coins, + const struct TALER_MERCHANT_PayCoin *coins, + TALER_MERCHANT_PayRefundCallback payref_cb, + void *payref_cb_cls); /** @@ -534,9 +545,10 @@ struct TALER_MERCHANT_PaidCoin */ struct TALER_MERCHANT_Pay * TALER_MERCHANT_pay_frontend (struct GNUNET_CURL_Context *ctx, - const char *merchant_url, - const struct TALER_MerchantPublicKeyP *merchant_pub, - const char *order_id, + const char *merchant_url, + const struct + TALER_MerchantPublicKeyP *merchant_pub, + const char *order_id, unsigned int num_coins, const struct TALER_MERCHANT_PaidCoin *coins, TALER_MERCHANT_PayCallback pay_cb, @@ -607,13 +619,17 @@ struct TALER_MERCHANT_TrackTransferDetails typedef void (*TALER_MERCHANT_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, - const struct TALER_Amount *total_amount, + const struct + TALER_Amount *total_amount, unsigned int details_length, - const struct TALER_MERCHANT_TrackTransferDetails *details); + const struct + TALER_MERCHANT_TrackTransferDetails * + details); /** @@ -631,10 +647,12 @@ typedef void struct TALER_MERCHANT_TrackTransferHandle * TALER_MERCHANT_track_transfer (struct GNUNET_CURL_Context *ctx, const char *backend_url, - const char *wire_method, - const struct TALER_WireTransferIdentifierRawP *wtid, + const char *wire_method, + const struct + TALER_WireTransferIdentifierRawP *wtid, const char *exchange_url, - TALER_MERCHANT_TrackTransferCallback track_transfer_cb, + TALER_MERCHANT_TrackTransferCallback + track_transfer_cb, void *track_transfer_cb_cls); @@ -645,7 +663,8 @@ TALER_MERCHANT_track_transfer (struct GNUNET_CURL_Context *ctx, * @param co the deposit's tracking operation */ void -TALER_MERCHANT_track_transfer_cancel (struct TALER_MERCHANT_TrackTransferHandle *tdo); +TALER_MERCHANT_track_transfer_cancel (struct + TALER_MERCHANT_TrackTransferHandle *tdo); /* ********************* /track/transaction *********************** */ @@ -694,7 +713,7 @@ struct TALER_MERCHANT_CoinWireTransfer typedef void (*TALER_MERCHANT_TrackTransactionCallback) (void *cls, unsigned int http_status, - enum TALER_ErrorCode ec, + enum TALER_ErrorCode ec, const json_t *json); @@ -712,7 +731,8 @@ struct TALER_MERCHANT_TrackTransactionHandle * TALER_MERCHANT_track_transaction (struct GNUNET_CURL_Context *ctx, const char *backend_url, const char *order_id, - TALER_MERCHANT_TrackTransactionCallback track_transaction_cb, + TALER_MERCHANT_TrackTransactionCallback + track_transaction_cb, void *track_transaction_cb_cls); @@ -723,7 +743,9 @@ TALER_MERCHANT_track_transaction (struct GNUNET_CURL_Context *ctx, * @param co the deposit's tracking operation */ void -TALER_MERCHANT_track_transaction_cancel (struct TALER_MERCHANT_TrackTransactionHandle *tdo); +TALER_MERCHANT_track_transaction_cancel (struct + TALER_MERCHANT_TrackTransactionHandle * + tdo); /* ********************* /history *********************** */ @@ -742,7 +764,7 @@ struct TALER_MERCHANT_HistoryOperation; typedef void (*TALER_MERCHANT_HistoryOperationCallback) (void *cls, unsigned int http_status, - enum TALER_ErrorCode ec, + enum TALER_ErrorCode ec, const json_t *json); /** @@ -784,7 +806,8 @@ TALER_MERCHANT_history_default_start (struct GNUNET_CURL_Context *ctx, const char *backend_url, long long delta, struct GNUNET_TIME_Absolute date, - TALER_MERCHANT_HistoryOperationCallback history_cb, + TALER_MERCHANT_HistoryOperationCallback + history_cb, void *history_cb_cls); @@ -855,7 +878,8 @@ TALER_MERCHANT_tip_authorize (struct GNUNET_CURL_Context *ctx, * @param ta handle from the operation to cancel */ void -TALER_MERCHANT_tip_authorize_cancel (struct TALER_MERCHANT_TipAuthorizeOperation *ta); +TALER_MERCHANT_tip_authorize_cancel (struct + TALER_MERCHANT_TipAuthorizeOperation *ta); /* ********************** /tip-pickup ************************* */ @@ -882,9 +906,11 @@ typedef void (*TALER_MERCHANT_TipPickupCallback) (void *cls, unsigned int http_status, enum TALER_ErrorCode ec, - const struct TALER_ReservePublicKeyP *reserve_pub, + const struct + TALER_ReservePublicKeyP *reserve_pub, unsigned int num_reserve_sigs, - const struct TALER_ReserveSignatureP *reserve_sigs, + const struct + TALER_ReserveSignatureP *reserve_sigs, const json_t *json); @@ -947,8 +973,8 @@ struct TALER_MERCHANT_CheckPaymentOperation; */ typedef void (*TALER_MERCHANT_CheckPaymentCallback) (void *cls, - unsigned int http_status, - const json_t *obj, + unsigned int http_status, + const json_t *obj, int paid, int refunded, struct TALER_Amount *refund_amount, @@ -962,7 +988,7 @@ typedef void * @param ctx execution context * @param backend_url base URL of the merchant backend * @param order_id order id to identify the payment - * @parem session_id sesion id for the payment (or NULL if the payment is not bound to a session) + * @parem session_id sesion id for the payment (or NULL if the payment is not bound to a session) * @param check_payment_cb callback which will work the response gotten from the backend * @param check_payment_cb_cls closure to pass to @a check_payment_cb * @return handle for this operation, NULL upon errors @@ -972,7 +998,8 @@ TALER_MERCHANT_check_payment (struct GNUNET_CURL_Context *ctx, const char *backend_url, const char *order_id, const char *session_id, - TALER_MERCHANT_CheckPaymentCallback check_payment_cb, + TALER_MERCHANT_CheckPaymentCallback + check_payment_cb, void *check_payment_cls); /** @@ -981,7 +1008,8 @@ TALER_MERCHANT_check_payment (struct GNUNET_CURL_Context *ctx, * @param cpo handle to the request to be canceled */ void -TALER_MERCHANT_check_payment_cancel (struct TALER_MERCHANT_CheckPaymentOperation *cpo); +TALER_MERCHANT_check_payment_cancel (struct + TALER_MERCHANT_CheckPaymentOperation *cpo); /* ********************** /tip-query ************************* */ @@ -1010,7 +1038,8 @@ typedef void unsigned int http_status, enum TALER_ErrorCode ec, const json_t *raw, - struct GNUNET_TIME_Absolute reserve_expiration, + struct GNUNET_TIME_Absolute + reserve_expiration, struct TALER_ReservePublicKeyP *reserve_pub, struct TALER_Amount *amount_authorized, struct TALER_Amount *amount_available, diff --git a/src/include/taler_merchant_testing_lib.h b/src/include/taler_merchant_testing_lib.h index b250af62..93b92fad 100644 --- a/src/include/taler_merchant_testing_lib.h +++ b/src/include/taler_merchant_testing_lib.h @@ -94,12 +94,11 @@ TALER_TESTING_cmd_proposal (const char *label, * @return the command. */ struct TALER_TESTING_Command -TALER_TESTING_cmd_proposal_lookup - (const char *label, - const char *merchant_url, - unsigned int http_status, - const char *proposal_reference, - const char *order_id); +TALER_TESTING_cmd_proposal_lookup (const char *label, + const char *merchant_url, + unsigned int http_status, + const char *proposal_reference, + const char *order_id); /** * Make a "check payment" test command. @@ -198,13 +197,12 @@ TALER_TESTING_cmd_pay_abort (const char *label, * @param http_status expected HTTP response code. */ struct TALER_TESTING_Command -TALER_TESTING_cmd_pay_abort_refund - (const char *label, - const char *abort_reference, - unsigned int num_coins, - const char *refund_amount, - const char *refund_fee, - unsigned int http_status); +TALER_TESTING_cmd_pay_abort_refund (const char *label, + const char *abort_reference, + unsigned int num_coins, + const char *refund_amount, + const char *refund_fee, + unsigned int http_status); /** * Define a "refund lookup" CMD. @@ -224,13 +222,12 @@ TALER_TESTING_cmd_pay_abort_refund * @return the command. */ struct TALER_TESTING_Command -TALER_TESTING_cmd_refund_lookup - (const char *label, - const char *merchant_url, - const char *increase_reference, - const char *pay_reference, - const char *order_id, - unsigned int http_code); +TALER_TESTING_cmd_refund_lookup (const char *label, + const char *merchant_url, + const char *increase_reference, + const char *pay_reference, + const char *order_id, + unsigned int http_code); /** * Define a "refund lookup" CMD, equipped with a expected refund @@ -254,14 +251,13 @@ TALER_TESTING_cmd_refund_lookup * @return the command. */ struct TALER_TESTING_Command -TALER_TESTING_cmd_refund_lookup_with_amount - (const char *label, - const char *merchant_url, - const char *increase_reference, - const char *pay_reference, - const char *order_id, - unsigned int http_code, - const char *refund_amount); +TALER_TESTING_cmd_refund_lookup_with_amount (const char *label, + const char *merchant_url, + const char *increase_reference, + const char *pay_reference, + const char *order_id, + unsigned int http_code, + const char *refund_amount); /** @@ -279,14 +275,13 @@ TALER_TESTING_cmd_refund_lookup_with_amount * @return the command. */ struct TALER_TESTING_Command -TALER_TESTING_cmd_refund_increase - (const char *label, - const char *merchant_url, - const char *reason, - const char *order_id, - const char *refund_amount, - const char *refund_fee, - unsigned int http_code); +TALER_TESTING_cmd_refund_increase (const char *label, + const char *merchant_url, + const char *reason, + const char *order_id, + const char *refund_amount, + const char *refund_fee, + unsigned int http_code); /** * Make a "history" command. @@ -301,13 +296,12 @@ TALER_TESTING_cmd_refund_increase * @param nrows how many row we want to receive, at most. */ struct TALER_TESTING_Command -TALER_TESTING_cmd_history_default_start - (const char *label, - const char *merchant_url, - unsigned int http_status, - struct GNUNET_TIME_Absolute time, - unsigned int nresult, - long long nrows); +TALER_TESTING_cmd_history_default_start (const char *label, + const char *merchant_url, + unsigned int http_status, + struct GNUNET_TIME_Absolute time, + unsigned int nresult, + long long nrows); /** * Make a "history" command. @@ -341,11 +335,10 @@ TALER_TESTING_cmd_history (const char *label, * @param pay_reference used to retrieve the order id to track. */ struct TALER_TESTING_Command -TALER_TESTING_cmd_merchant_track_transaction - (const char *label, - const char *merchant_url, - unsigned int http_status, - const char *pay_reference); +TALER_TESTING_cmd_merchant_track_transaction (const char *label, + const char *merchant_url, + unsigned int http_status, + const char *pay_reference); /** * Define a "track transfer" CMD. @@ -360,11 +353,10 @@ TALER_TESTING_cmd_merchant_track_transaction * @param pay_reference FIXME not used. */ struct TALER_TESTING_Command -TALER_TESTING_cmd_merchant_track_transfer - (const char *label, - const char *merchant_url, - unsigned int http_status, - const char *check_bank_reference); +TALER_TESTING_cmd_merchant_track_transfer (const char *label, + const char *merchant_url, + unsigned int http_status, + const char *check_bank_reference); /* ****** Specific traits supported by this component ******* */ @@ -378,9 +370,9 @@ TALER_TESTING_cmd_merchant_track_transfer * @return the trait */ struct TALER_TESTING_Trait -TALER_TESTING_make_trait_merchant_sig - (unsigned int index, - const struct TALER_MerchantSignatureP *merchant_sig); +TALER_TESTING_make_trait_merchant_sig (unsigned int index, + const struct + TALER_MerchantSignatureP *merchant_sig); /** * Obtain a merchant signature over a contract from a @a cmd. @@ -393,10 +385,10 @@ TALER_TESTING_make_trait_merchant_sig * @return #GNUNET_OK on success */ int -TALER_TESTING_get_trait_merchant_sig - (const struct TALER_TESTING_Command *cmd, - unsigned int index, - struct TALER_MerchantSignatureP **merchant_sig); +TALER_TESTING_get_trait_merchant_sig (const struct TALER_TESTING_Command *cmd, + unsigned int index, + struct TALER_MerchantSignatureP ** + merchant_sig); /** * Obtain a reference to a proposal command. Any command that @@ -414,10 +406,10 @@ TALER_TESTING_get_trait_merchant_sig * @return #GNUNET_OK on success */ int -TALER_TESTING_get_trait_proposal_reference - (const struct TALER_TESTING_Command *cmd, - unsigned int index, - const char **proposal_reference); +TALER_TESTING_get_trait_proposal_reference (const struct + TALER_TESTING_Command *cmd, + unsigned int index, + const char **proposal_reference); /** * Offer a proposal reference. @@ -429,9 +421,8 @@ TALER_TESTING_get_trait_proposal_reference * @return the trait */ struct TALER_TESTING_Trait -TALER_TESTING_make_trait_proposal_reference - (unsigned int index, - const char *proposal_reference); +TALER_TESTING_make_trait_proposal_reference (unsigned int index, + const char *proposal_reference); /** * Offer a coin reference. @@ -443,9 +434,8 @@ TALER_TESTING_make_trait_proposal_reference * @return the trait */ struct TALER_TESTING_Trait -TALER_TESTING_make_trait_coin_reference - (unsigned int index, - const char *coin_reference); +TALER_TESTING_make_trait_coin_reference (unsigned int index, + const char *coin_reference); /** * Obtain a reference to any command that can provide coins as @@ -465,10 +455,9 @@ TALER_TESTING_make_trait_coin_reference * @return #GNUNET_OK on success */ int -TALER_TESTING_get_trait_coin_reference - (const struct TALER_TESTING_Command *cmd, - unsigned int index, - const char **coin_reference); +TALER_TESTING_get_trait_coin_reference (const struct TALER_TESTING_Command *cmd, + unsigned int index, + const char **coin_reference); /** @@ -481,10 +470,11 @@ TALER_TESTING_get_trait_coin_reference * @return #GNUNET_OK on success */ int -TALER_TESTING_get_trait_planchet_secrets - (const struct TALER_TESTING_Command *cmd, - unsigned int index, - struct TALER_PlanchetSecretsP **planchet_secrets); +TALER_TESTING_get_trait_planchet_secrets (const struct + TALER_TESTING_Command *cmd, + unsigned int index, + struct TALER_PlanchetSecretsP ** + planchet_secrets); /** * Offer planchet secrets. @@ -495,9 +485,10 @@ TALER_TESTING_get_trait_planchet_secrets * @return the trait */ struct TALER_TESTING_Trait -TALER_TESTING_make_trait_planchet_secrets - (unsigned int index, - const struct TALER_PlanchetSecretsP *planchet_secrets); +TALER_TESTING_make_trait_planchet_secrets (unsigned int index, + const struct + TALER_PlanchetSecretsP * + planchet_secrets); /** * Offer tip id. @@ -508,9 +499,8 @@ TALER_TESTING_make_trait_planchet_secrets * @return the trait */ struct TALER_TESTING_Trait -TALER_TESTING_make_trait_tip_id - (unsigned int index, - const struct GNUNET_HashCode *tip_id); +TALER_TESTING_make_trait_tip_id (unsigned int index, + const struct GNUNET_HashCode *tip_id); /** * Obtain tip id from a @a cmd. @@ -523,10 +513,9 @@ TALER_TESTING_make_trait_tip_id * @return #GNUNET_OK on success */ int -TALER_TESTING_get_trait_tip_id - (const struct TALER_TESTING_Command *cmd, - unsigned int index, - const struct GNUNET_HashCode **tip_id); +TALER_TESTING_get_trait_tip_id (const struct TALER_TESTING_Command *cmd, + unsigned int index, + const struct GNUNET_HashCode **tip_id); /** * Offer contract terms hash code. @@ -539,9 +528,9 @@ TALER_TESTING_get_trait_tip_id * @return the trait */ struct TALER_TESTING_Trait -TALER_TESTING_make_trait_h_contract_terms - (unsigned int index, - const struct GNUNET_HashCode *h_contract_terms); +TALER_TESTING_make_trait_h_contract_terms (unsigned int index, + const struct + GNUNET_HashCode *h_contract_terms); /** * Obtain contract terms hash from a @a cmd. @@ -553,10 +542,11 @@ TALER_TESTING_make_trait_h_contract_terms * @return #GNUNET_OK on success */ int -TALER_TESTING_get_trait_h_contract_terms - (const struct TALER_TESTING_Command *cmd, - unsigned int index, - const struct GNUNET_HashCode **h_contract_terms); +TALER_TESTING_get_trait_h_contract_terms (const struct + TALER_TESTING_Command *cmd, + unsigned int index, + const struct + GNUNET_HashCode **h_contract_terms); /** * Offer refund entry. @@ -567,9 +557,9 @@ TALER_TESTING_get_trait_h_contract_terms * @return the trait */ struct TALER_TESTING_Trait -TALER_TESTING_make_trait_refund_entry - (unsigned int index, - const struct TALER_MERCHANT_RefundEntry *refund_entry); +TALER_TESTING_make_trait_refund_entry (unsigned int index, + const struct + TALER_MERCHANT_RefundEntry *refund_entry); /** @@ -582,10 +572,10 @@ TALER_TESTING_make_trait_refund_entry * @return #GNUNET_OK on success */ int -TALER_TESTING_get_trait_refund_entry - (const struct TALER_TESTING_Command *cmd, - unsigned int index, - const struct TALER_MERCHANT_RefundEntry **refund_entry); +TALER_TESTING_get_trait_refund_entry (const struct TALER_TESTING_Command *cmd, + unsigned int index, + const struct + TALER_MERCHANT_RefundEntry **refund_entry); /** * Create a /tip-authorize CMD, specifying the Taler error code @@ -604,14 +594,13 @@ TALER_TESTING_get_trait_refund_entry * @param ec expected Taler-defined error code. */ struct TALER_TESTING_Command -TALER_TESTING_cmd_tip_authorize_with_ec - (const char *label, - const char *merchant_url, - const char *exchange_url, - unsigned int http_status, - const char *justification, - const char *amount, - enum TALER_ErrorCode ec); +TALER_TESTING_cmd_tip_authorize_with_ec (const char *label, + const char *merchant_url, + const char *exchange_url, + unsigned int http_status, + const char *justification, + const char *amount, + enum TALER_ErrorCode ec); /** @@ -625,8 +614,7 @@ TALER_TESTING_cmd_tip_authorize_with_ec * @return the command. */ struct TALER_TESTING_Command -TALER_TESTING_cmd_tip_authorize_fake - (const char *label); +TALER_TESTING_cmd_tip_authorize_fake (const char *label); /** * Create a /tip-authorize CMD. @@ -678,13 +666,12 @@ TALER_TESTING_cmd_tip_query (const char *label, * @param expected_amount_available FIXME what is this? */ struct TALER_TESTING_Command -TALER_TESTING_cmd_tip_query_with_amounts - (const char *label, - const char *merchant_url, - unsigned int http_status, - const char *expected_amount_picked_up, - const char *expected_amount_authorized, - const char *expected_amount_available); +TALER_TESTING_cmd_tip_query_with_amounts (const char *label, + const char *merchant_url, + unsigned int http_status, + const char *expected_amount_picked_up, + const char *expected_amount_authorized, + const char *expected_amount_available); /** * Define a /tip-pickup CMD, equipped with the expected error @@ -701,13 +688,12 @@ TALER_TESTING_cmd_tip_query_with_amounts * @param ec expected Taler error code. */ struct TALER_TESTING_Command -TALER_TESTING_cmd_tip_pickup_with_ec - (const char *label, - const char *merchant_url, - unsigned int http_status, - const char *authorize_reference, - const char **amounts, - enum TALER_ErrorCode ec); +TALER_TESTING_cmd_tip_pickup_with_ec (const char *label, + const char *merchant_url, + unsigned int http_status, + const char *authorize_reference, + const char **amounts, + enum TALER_ErrorCode ec); /** * Define a /tip-pickup CMD. @@ -722,12 +708,11 @@ TALER_TESTING_cmd_tip_pickup_with_ec * which denominations will be accepted for tipping. */ struct TALER_TESTING_Command -TALER_TESTING_cmd_tip_pickup - (const char *label, - const char *merchant_url, - unsigned int http_status, - const char *authorize_reference, - const char **amounts); +TALER_TESTING_cmd_tip_pickup (const char *label, + const char *merchant_url, + unsigned int http_status, + const char *authorize_reference, + const char **amounts); /** * Make the instruction pointer point to @a new_ip @@ -743,9 +728,8 @@ TALER_TESTING_cmd_tip_pickup * to happen. */ struct TALER_TESTING_Command -TALER_TESTING_cmd_rewind_ip - (const char *label, - int new_ip, - unsigned int *counter); +TALER_TESTING_cmd_rewind_ip (const char *label, + int new_ip, + unsigned int *counter); #endif diff --git a/src/include/taler_merchantdb_plugin.h b/src/include/taler_merchantdb_plugin.h index 04fb2664..59cd2db6 100644 --- a/src/include/taler_merchantdb_plugin.h +++ b/src/include/taler_merchantdb_plugin.h @@ -40,11 +40,11 @@ struct TALER_MERCHANTDB_Plugin; * @param row_id serial numer of the transaction in the table, * @param contract_terms proposal data related to order id */ - typedef void - (*TALER_MERCHANTDB_ProposalDataCallback)(void *cls, - const char *order_id, - uint64_t row_id, - const json_t *contract_terms); +typedef void +(*TALER_MERCHANTDB_ProposalDataCallback)(void *cls, + const char *order_id, + uint64_t row_id, + const json_t *contract_terms); /** * Function called with information about a transaction. @@ -59,12 +59,15 @@ struct TALER_MERCHANTDB_Plugin; */ typedef void (*TALER_MERCHANTDB_TransactionCallback)(void *cls, - const struct TALER_MerchantPublicKeyP *merchant_pub, - const struct GNUNET_HashCode *h_contract_terms, + const struct + TALER_MerchantPublicKeyP *merchant_pub, + const struct + GNUNET_HashCode *h_contract_terms, const struct GNUNET_HashCode *h_wire, struct GNUNET_TIME_Absolute timestamp, struct GNUNET_TIME_Absolute refund, - const struct TALER_Amount *total_amount); + const struct + TALER_Amount *total_amount); /** @@ -83,10 +86,13 @@ typedef void */ typedef void (*TALER_MERCHANTDB_CoinDepositCallback)(void *cls, - 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, const char *exchange_url, - const struct TALER_Amount *amount_with_fee, + const struct + TALER_Amount *amount_with_fee, const struct TALER_Amount *deposit_fee, const struct TALER_Amount *refund_fee, const struct TALER_Amount *wire_fee, @@ -112,9 +118,12 @@ typedef void */ typedef void (*TALER_MERCHANTDB_TransferCallback)(void *cls, - const struct GNUNET_HashCode *h_contract_terms, - const struct TALER_CoinSpendPublicKeyP *coin_pub, - const struct TALER_WireTransferIdentifierRawP *wtid, + const struct + GNUNET_HashCode *h_contract_terms, + const struct + TALER_CoinSpendPublicKeyP *coin_pub, + const struct + TALER_WireTransferIdentifierRawP *wtid, struct GNUNET_TIME_Absolute execution_time, const json_t *exchange_proof); @@ -142,7 +151,8 @@ typedef void */ typedef void (*TALER_MERCHANTDB_RefundCallback)(void *cls, - const struct TALER_CoinSpendPublicKeyP *coin_pub, + const struct + TALER_CoinSpendPublicKeyP *coin_pub, uint64_t rtransaction_id, const char *reason, const struct TALER_Amount *refund_amount, @@ -201,11 +211,11 @@ struct TALER_MERCHANTDB_Plugin * @return transaction status */ enum GNUNET_DB_QueryStatus - (*insert_order) (void *cls, - const char *order_id, - const struct TALER_MerchantPublicKeyP *merchant_pub, - struct GNUNET_TIME_Absolute timestamp, - const json_t *contract_terms); + (*insert_order)(void *cls, + const char *order_id, + const struct TALER_MerchantPublicKeyP *merchant_pub, + struct GNUNET_TIME_Absolute timestamp, + const json_t *contract_terms); /** @@ -220,11 +230,11 @@ struct TALER_MERCHANTDB_Plugin * @return transaction status */ enum GNUNET_DB_QueryStatus - (*insert_contract_terms) (void *cls, - const char *order_id, - const struct TALER_MerchantPublicKeyP *merchant_pub, - struct GNUNET_TIME_Absolute timestamp, - const json_t *contract_terms); + (*insert_contract_terms)(void *cls, + const char *order_id, + const struct TALER_MerchantPublicKeyP *merchant_pub, + struct GNUNET_TIME_Absolute timestamp, + const json_t *contract_terms); /** * Mark contract terms as payed. Needed by /history as only payed @@ -242,9 +252,9 @@ struct TALER_MERCHANTDB_Plugin * @return transaction status */ enum GNUNET_DB_QueryStatus - (*mark_proposal_paid) (void *cls, - const struct GNUNET_HashCode *h_contract_terms, - const struct TALER_MerchantPublicKeyP *merchant_pub); + (*mark_proposal_paid)(void *cls, + const struct GNUNET_HashCode *h_contract_terms, + const struct TALER_MerchantPublicKeyP *merchant_pub); /** * Store the order ID that was used to pay for a resource within a session. @@ -258,11 +268,11 @@ struct TALER_MERCHANTDB_Plugin * @return transaction status */ enum GNUNET_DB_QueryStatus - (*insert_session_info) (void *cls, - const char *session_id, - const char *fulfillment_url, - const char *order_id, - const struct TALER_MerchantPublicKeyP *merchant_pub); + (*insert_session_info)(void *cls, + const char *session_id, + const char *fulfillment_url, + const char *order_id, + const struct TALER_MerchantPublicKeyP *merchant_pub); /** * Retrieve the order ID that was used to pay for a resource within a session. @@ -277,11 +287,11 @@ struct TALER_MERCHANTDB_Plugin * @return transaction status */ enum GNUNET_DB_QueryStatus - (*find_session_info) (void *cls, - char **order_id, - const char *session_id, - const char *fulfillment_url, - const struct TALER_MerchantPublicKeyP *merchant_pub); + (*find_session_info)(void *cls, + char **order_id, + const char *session_id, + const char *fulfillment_url, + const struct TALER_MerchantPublicKeyP *merchant_pub); /** * Retrieve proposal data given its order ID. @@ -293,7 +303,7 @@ struct TALER_MERCHANTDB_Plugin * @return transaction status */ enum GNUNET_DB_QueryStatus - (*find_contract_terms) (void *cls, + (*find_contract_terms)(void *cls, json_t **contract_terms, const char *order_id, const struct TALER_MerchantPublicKeyP *merchant_pub); @@ -308,10 +318,10 @@ struct TALER_MERCHANTDB_Plugin * @return transaction status */ enum GNUNET_DB_QueryStatus - (*find_order) (void *cls, - json_t **contract_terms, - const char *order_id, - const struct TALER_MerchantPublicKeyP *merchant_pub); + (*find_order)(void *cls, + json_t **contract_terms, + const char *order_id, + const struct TALER_MerchantPublicKeyP *merchant_pub); /** @@ -324,10 +334,12 @@ struct TALER_MERCHANTDB_Plugin * @return transaction status */ enum GNUNET_DB_QueryStatus - (*find_contract_terms_from_hash) (void *cls, + (*find_contract_terms_from_hash)(void *cls, json_t **contract_terms, - const struct GNUNET_HashCode *h_contract_terms, - const struct TALER_MerchantPublicKeyP *merchant_pub); + const struct + GNUNET_HashCode *h_contract_terms, + const struct + TALER_MerchantPublicKeyP *merchant_pub); /** @@ -340,10 +352,12 @@ struct TALER_MERCHANTDB_Plugin * @return transaction status */ enum GNUNET_DB_QueryStatus - (*find_paid_contract_terms_from_hash) (void *cls, - json_t **contract_terms, - const struct GNUNET_HashCode *h_contract_terms, - const struct TALER_MerchantPublicKeyP *merchant_pub); + (*find_paid_contract_terms_from_hash)(void *cls, + json_t **contract_terms, + const struct + GNUNET_HashCode *h_contract_terms, + const struct + TALER_MerchantPublicKeyP *merchant_pub); /** @@ -366,15 +380,18 @@ struct TALER_MERCHANTDB_Plugin * @return transaction status */ enum GNUNET_DB_QueryStatus - (*find_contract_terms_by_date_and_range) (void *cls, - struct GNUNET_TIME_Absolute date, - const struct TALER_MerchantPublicKeyP *merchant_pub, - uint64_t start, - uint64_t nrows, - int past, - unsigned int ascending, - TALER_MERCHANTDB_ProposalDataCallback cb, - void *cb_cls); + (*find_contract_terms_by_date_and_range)(void *cls, + struct GNUNET_TIME_Absolute date, + const struct + TALER_MerchantPublicKeyP * + merchant_pub, + uint64_t start, + uint64_t nrows, + int past, + unsigned int ascending, + TALER_MERCHANTDB_ProposalDataCallback + cb, + void *cb_cls); /** * Lookup for a proposal, respecting the signature used by the @@ -388,9 +405,10 @@ struct TALER_MERCHANTDB_Plugin * @return transaction status */ enum GNUNET_DB_QueryStatus - (*find_contract_terms_history) (void *cls, + (*find_contract_terms_history)(void *cls, const char *order_id, - const struct TALER_MerchantPublicKeyP *merchant_pub, + const struct + TALER_MerchantPublicKeyP *merchant_pub, TALER_MERCHANTDB_ProposalDataCallback cb, void *cb_cls); @@ -409,12 +427,13 @@ struct TALER_MERCHANTDB_Plugin * @return transaction status */ enum GNUNET_DB_QueryStatus - (*find_contract_terms_by_date) (void *cls, - struct GNUNET_TIME_Absolute date, - const struct TALER_MerchantPublicKeyP *merchant_pub, - uint64_t nrows, - TALER_MERCHANTDB_ProposalDataCallback cb, - void *cb_cls); + (*find_contract_terms_by_date)(void *cls, + struct GNUNET_TIME_Absolute date, + const struct + TALER_MerchantPublicKeyP *merchant_pub, + uint64_t nrows, + TALER_MERCHANTDB_ProposalDataCallback cb, + void *cb_cls); /** @@ -433,17 +452,17 @@ struct TALER_MERCHANTDB_Plugin * @return transaction status */ enum GNUNET_DB_QueryStatus - (*store_deposit) (void *cls, - const struct GNUNET_HashCode *h_contract_terms, - const struct TALER_MerchantPublicKeyP *merchant_pub, - const struct TALER_CoinSpendPublicKeyP *coin_pub, - const char *exchange_url, - const struct TALER_Amount *amount_with_fee, - const struct TALER_Amount *deposit_fee, - const struct TALER_Amount *refund_fee, - const struct TALER_Amount *wire_fee, - const struct TALER_ExchangePublicKeyP *signkey_pub, - const json_t *exchange_proof); + (*store_deposit)(void *cls, + const struct GNUNET_HashCode *h_contract_terms, + const struct TALER_MerchantPublicKeyP *merchant_pub, + const struct TALER_CoinSpendPublicKeyP *coin_pub, + const char *exchange_url, + const struct TALER_Amount *amount_with_fee, + const struct TALER_Amount *deposit_fee, + const struct TALER_Amount *refund_fee, + const struct TALER_Amount *wire_fee, + const struct TALER_ExchangePublicKeyP *signkey_pub, + const json_t *exchange_proof); /** @@ -458,10 +477,11 @@ struct TALER_MERCHANTDB_Plugin * @return transaction status */ enum GNUNET_DB_QueryStatus - (*store_coin_to_transfer) (void *cls, - const struct GNUNET_HashCode *h_contract_terms, - const struct TALER_CoinSpendPublicKeyP *coin_pub, - const struct TALER_WireTransferIdentifierRawP *wtid); + (*store_coin_to_transfer)(void *cls, + const struct GNUNET_HashCode *h_contract_terms, + const struct TALER_CoinSpendPublicKeyP *coin_pub, + const struct + TALER_WireTransferIdentifierRawP *wtid); /** @@ -476,12 +496,13 @@ struct TALER_MERCHANTDB_Plugin * @return transaction status */ enum GNUNET_DB_QueryStatus - (*store_transfer_to_proof) (void *cls, - const char *exchange_url, - const struct TALER_WireTransferIdentifierRawP *wtid, - struct GNUNET_TIME_Absolute execution_time, - const struct TALER_ExchangePublicKeyP *signkey_pub, - const json_t *exchange_proof); + (*store_transfer_to_proof)(void *cls, + const char *exchange_url, + const struct + TALER_WireTransferIdentifierRawP *wtid, + struct GNUNET_TIME_Absolute execution_time, + const struct TALER_ExchangePublicKeyP *signkey_pub, + const json_t *exchange_proof); /** @@ -500,14 +521,16 @@ struct TALER_MERCHANTDB_Plugin * @return transaction status code */ enum GNUNET_DB_QueryStatus - (*store_wire_fee_by_exchange) (void *cls, - const struct TALER_MasterPublicKeyP *exchange_pub, - const struct GNUNET_HashCode *h_wire_method, - const struct TALER_Amount *wire_fee, - const struct TALER_Amount *closing_fee, - struct GNUNET_TIME_Absolute start_date, - struct GNUNET_TIME_Absolute end_date, - const struct TALER_MasterSignatureP *exchange_sig); + (*store_wire_fee_by_exchange)(void *cls, + const struct + TALER_MasterPublicKeyP *exchange_pub, + const struct GNUNET_HashCode *h_wire_method, + const struct TALER_Amount *wire_fee, + const struct TALER_Amount *closing_fee, + struct GNUNET_TIME_Absolute start_date, + struct GNUNET_TIME_Absolute end_date, + const struct + TALER_MasterSignatureP *exchange_sig); @@ -523,11 +546,11 @@ struct TALER_MERCHANTDB_Plugin * @return transaction status */ enum GNUNET_DB_QueryStatus - (*find_payments) (void *cls, - const struct GNUNET_HashCode *h_contract_terms, - const struct TALER_MerchantPublicKeyP *merchant_pub, - TALER_MERCHANTDB_CoinDepositCallback cb, - void *cb_cls); + (*find_payments)(void *cls, + const struct GNUNET_HashCode *h_contract_terms, + const struct TALER_MerchantPublicKeyP *merchant_pub, + TALER_MERCHANTDB_CoinDepositCallback cb, + void *cb_cls); /** @@ -543,12 +566,15 @@ struct TALER_MERCHANTDB_Plugin * @return transaction status */ enum GNUNET_DB_QueryStatus - (*find_payments_by_hash_and_coin) (void *cls, - const struct GNUNET_HashCode *h_contract_terms, - const struct TALER_MerchantPublicKeyP *merchant_pub, - const struct TALER_CoinSpendPublicKeyP *coin_pub, - TALER_MERCHANTDB_CoinDepositCallback cb, - void *cb_cls); + (*find_payments_by_hash_and_coin)(void *cls, + const struct + GNUNET_HashCode *h_contract_terms, + const struct + TALER_MerchantPublicKeyP *merchant_pub, + const struct + TALER_CoinSpendPublicKeyP *coin_pub, + TALER_MERCHANTDB_CoinDepositCallback cb, + void *cb_cls); /** @@ -565,10 +591,10 @@ struct TALER_MERCHANTDB_Plugin * @return transaction status */ enum GNUNET_DB_QueryStatus - (*find_transfers_by_hash) (void *cls, - const struct GNUNET_HashCode *h_contract_terms, - TALER_MERCHANTDB_TransferCallback cb, - void *cb_cls); + (*find_transfers_by_hash)(void *cls, + const struct GNUNET_HashCode *h_contract_terms, + TALER_MERCHANTDB_TransferCallback cb, + void *cb_cls); /** @@ -581,10 +607,10 @@ struct TALER_MERCHANTDB_Plugin * @return transaction status */ enum GNUNET_DB_QueryStatus - (*find_deposits_by_wtid) (void *cls, - const struct TALER_WireTransferIdentifierRawP *wtid, - TALER_MERCHANTDB_CoinDepositCallback cb, - void *cb_cls); + (*find_deposits_by_wtid)(void *cls, + const struct TALER_WireTransferIdentifierRawP *wtid, + TALER_MERCHANTDB_CoinDepositCallback cb, + void *cb_cls); /** @@ -598,11 +624,11 @@ struct TALER_MERCHANTDB_Plugin * @return transaction status */ enum GNUNET_DB_QueryStatus - (*find_proof_by_wtid) (void *cls, - const char *exchange_url, - const struct TALER_WireTransferIdentifierRawP *wtid, - TALER_MERCHANTDB_ProofCallback cb, - void *cb_cls); + (*find_proof_by_wtid)(void *cls, + const char *exchange_url, + const struct TALER_WireTransferIdentifierRawP *wtid, + TALER_MERCHANTDB_ProofCallback cb, + void *cb_cls); /** @@ -622,15 +648,15 @@ struct TALER_MERCHANTDB_Plugin * @return transaction status code */ enum GNUNET_DB_QueryStatus - (*lookup_wire_fee) (void *cls, - const struct TALER_MasterPublicKeyP *exchange_pub, - const struct GNUNET_HashCode *h_wire_method, - struct GNUNET_TIME_Absolute contract_date, - struct TALER_Amount *wire_fee, - struct TALER_Amount *closing_fee, - struct GNUNET_TIME_Absolute *start_date, - struct GNUNET_TIME_Absolute *end_date, - struct TALER_MasterSignatureP *exchange_sig); + (*lookup_wire_fee)(void *cls, + const struct TALER_MasterPublicKeyP *exchange_pub, + const struct GNUNET_HashCode *h_wire_method, + struct GNUNET_TIME_Absolute contract_date, + struct TALER_Amount *wire_fee, + struct TALER_Amount *closing_fee, + struct GNUNET_TIME_Absolute *start_date, + struct GNUNET_TIME_Absolute *end_date, + struct TALER_MasterSignatureP *exchange_sig); /** @@ -650,8 +676,10 @@ struct TALER_MERCHANTDB_Plugin */ enum GNUNET_DB_QueryStatus (*increase_refund_for_contract_NT)(void *cls, - const struct GNUNET_HashCode *h_contract_terms, - const struct TALER_MerchantPublicKeyP *merchant_pub, + const struct + GNUNET_HashCode *h_contract_terms, + const struct + TALER_MerchantPublicKeyP *merchant_pub, const struct TALER_Amount *refund, const char *reason); @@ -668,8 +696,10 @@ struct TALER_MERCHANTDB_Plugin */ enum GNUNET_DB_QueryStatus (*get_refunds_from_contract_terms_hash)(void *cls, - const struct TALER_MerchantPublicKeyP *merchant_pub, - const struct GNUNET_HashCode *h_contract_terms, + const struct + TALER_MerchantPublicKeyP *merchant_pub, + const struct + GNUNET_HashCode *h_contract_terms, TALER_MERCHANTDB_RefundCallback rc, void *rc_cls); @@ -741,7 +771,8 @@ struct TALER_MERCHANTDB_Plugin */ enum GNUNET_DB_QueryStatus (*get_authorized_tip_amount)(void *cls, - const struct TALER_ReservePrivateKeyP *reserve_priv, + const struct + TALER_ReservePrivateKeyP *reserve_priv, struct TALER_Amount *authorized_amount); @@ -833,7 +864,7 @@ struct TALER_MERCHANTDB_Plugin * @return transaction status code */ enum GNUNET_DB_QueryStatus - (*commit) (void *cls); + (*commit)(void *cls); }; diff --git a/src/lib/merchant_api_check_payment.c b/src/lib/merchant_api_check_payment.c index 8848686d..ba5ac770 100644 --- a/src/lib/merchant_api_check_payment.c +++ b/src/lib/merchant_api_check_payment.c @@ -81,13 +81,13 @@ handle_check_payment_finished (void *cls, struct TALER_Amount refund_amount = { 0 }; int refunded; const json_t *json = response; - + struct GNUNET_JSON_Specification spec[] = { GNUNET_JSON_spec_boolean ("refunded", &refunded), TALER_JSON_spec_amount ("refund_amount", &refund_amount), - GNUNET_JSON_spec_end() + GNUNET_JSON_spec_end () }; cpo->job = NULL; @@ -111,7 +111,8 @@ handle_check_payment_finished (void *cls, if (! json_boolean_value (json_object_get (json, "paid"))) { - const char *taler_pay_uri = json_string_value (json_object_get (json, "taler_pay_uri")); + const char *taler_pay_uri = json_string_value (json_object_get (json, + "taler_pay_uri")); if (NULL == taler_pay_uri) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, @@ -124,7 +125,8 @@ handle_check_payment_finished (void *cls, GNUNET_SYSERR, &refund_amount, NULL); - } else { + } + else { cpo->cb (cpo->cb_cls, response_code, json, @@ -175,7 +177,7 @@ handle_check_payment_finished (void *cls, * @param ctx execution context * @param backend_url base URL of the merchant backend * @param order_id order id to identify the payment - * @parem session_id sesion id for the payment (or NULL if the payment is not bound to a session) + * @parem session_id sesion id for the payment (or NULL if the payment is not bound to a session) * @param check_payment_cb callback which will work the response gotten from the backend * @param check_payment_cb_cls closure to pass to @a check_payment_cb * @return handle for this operation, NULL upon errors @@ -185,7 +187,8 @@ TALER_MERCHANT_check_payment (struct GNUNET_CURL_Context *ctx, const char *backend_url, const char *order_id, const char *session_id, - TALER_MERCHANT_CheckPaymentCallback check_payment_cb, + TALER_MERCHANT_CheckPaymentCallback + check_payment_cb, void *check_payment_cb_cls) { struct TALER_MERCHANT_CheckPaymentOperation *cpo; @@ -234,7 +237,8 @@ TALER_MERCHANT_check_payment (struct GNUNET_CURL_Context *ctx, * @param cph handle to the request to be canceled */ void -TALER_MERCHANT_check_payment_cancel (struct TALER_MERCHANT_CheckPaymentOperation *cph) +TALER_MERCHANT_check_payment_cancel (struct + TALER_MERCHANT_CheckPaymentOperation *cph) { if (NULL != cph->job) { diff --git a/src/lib/merchant_api_history.c b/src/lib/merchant_api_history.c index d1cbfcfa..4c23c010 100644 --- a/src/lib/merchant_api_history.c +++ b/src/lib/merchant_api_history.c @@ -119,17 +119,17 @@ history_raw_cb (void *cls, case MHD_HTTP_OK: ho->cb (ho->cb_cls, MHD_HTTP_OK, - TALER_EC_NONE, + TALER_EC_NONE, json); TALER_MERCHANT_history_cancel (ho); return; case MHD_HTTP_INTERNAL_SERVER_ERROR: GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "/history URL not found\n"); + "/history URL not found\n"); break; case MHD_HTTP_BAD_REQUEST: GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "Wrong/missing URL parameter\n"); + "Wrong/missing URL parameter\n"); break; default: /* unexpected response code */ @@ -143,7 +143,7 @@ history_raw_cb (void *cls, ho->cb (ho->cb_cls, response_code, - TALER_JSON_get_error_code (json), + TALER_JSON_get_error_code (json), json); TALER_MERCHANT_history_cancel (ho); } @@ -197,7 +197,7 @@ TALER_MERCHANT_history2 (struct GNUNET_CURL_Context *ctx, seconds, delta, start); - + GNUNET_free (base); @@ -243,18 +243,18 @@ TALER_MERCHANT_history2 (struct GNUNET_CURL_Context *ctx, struct TALER_MERCHANT_HistoryOperation * TALER_MERCHANT_history_default_start (struct GNUNET_CURL_Context *ctx, - const char *backend_url, - long long delta, - struct GNUNET_TIME_Absolute date, - TALER_MERCHANT_HistoryOperationCallback history_cb, - void *history_cb_cls) + const char *backend_url, + long long delta, + struct GNUNET_TIME_Absolute date, + TALER_MERCHANT_HistoryOperationCallback history_cb, + void *history_cb_cls) { return TALER_MERCHANT_history2 (ctx, backend_url, - /* fake 'start' argument: will NOT be used */ - -1, - /* Specifies "no start argument" in final URL */ - GNUNET_YES, + /* fake 'start' argument: will NOT be used */ + -1, + /* Specifies "no start argument" in final URL */ + GNUNET_YES, delta, date, history_cb, @@ -282,12 +282,12 @@ TALER_MERCHANT_history_default_start struct TALER_MERCHANT_HistoryOperation * TALER_MERCHANT_history (struct GNUNET_CURL_Context *ctx, - const char *backend_url, - unsigned long long start, - long long delta, - struct GNUNET_TIME_Absolute date, - TALER_MERCHANT_HistoryOperationCallback history_cb, - void *history_cb_cls) + const char *backend_url, + unsigned long long start, + long long delta, + struct GNUNET_TIME_Absolute date, + TALER_MERCHANT_HistoryOperationCallback history_cb, + void *history_cb_cls) { return TALER_MERCHANT_history2 (ctx, backend_url, diff --git a/src/lib/merchant_api_refund.c b/src/lib/merchant_api_refund.c index 21138184..5a6b0e39 100644 --- a/src/lib/merchant_api_refund.c +++ b/src/lib/merchant_api_refund.c @@ -140,16 +140,16 @@ handle_refund_increase_finished (void *cls, * need a link to error objects at docs) */ if (-1 == json_unpack - ((json_t *) json, - "{s:s, s:I, s:s}", - "error", &error, - "code", &code, - "hint", &hint)) + ((json_t *) json, + "{s:s, s:I, s:s}", + "error", &error, + "code", &code, + "hint", &hint)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "/refund failed (HTTP code: %lu), backend did " - "not give a valid error object\n", response_code); + "/refund failed (HTTP code: %lu), backend did " + "not give a valid error object\n", response_code); break; } @@ -169,7 +169,9 @@ handle_refund_increase_finished (void *cls, * @param rio the refund increasing operation to cancel */ void -TALER_MERCHANT_refund_increase_cancel (struct TALER_MERCHANT_RefundIncreaseOperation *rio) +TALER_MERCHANT_refund_increase_cancel (struct + TALER_MERCHANT_RefundIncreaseOperation * + rio) { if (NULL != rio->job) { @@ -232,11 +234,11 @@ TALER_MERCHANT_refund_increase (struct GNUNET_CURL_Context *ctx, CURLOPT_URL, rio->url)); rio->job = GNUNET_CURL_job_add2 - (ctx, - eh, - rio->post_ctx.headers, - &handle_refund_increase_finished, - rio); + (ctx, + eh, + rio->post_ctx.headers, + &handle_refund_increase_finished, + rio); return rio; } @@ -248,7 +250,8 @@ TALER_MERCHANT_refund_increase (struct GNUNET_CURL_Context *ctx, * @param */ void -TALER_MERCHANT_refund_lookup_cancel (struct TALER_MERCHANT_RefundLookupOperation *rlo) +TALER_MERCHANT_refund_lookup_cancel (struct + TALER_MERCHANT_RefundLookupOperation *rlo) { if (NULL != rlo->job) { @@ -296,9 +299,9 @@ handle_refund_lookup_finished (void *cls, * need a link to error objects at docs) */ if (-1 == json_unpack ((json_t *) json, - "{s:s, s:I, s:s}", - "error", &error, - "code", &code)) + "{s:s, s:I, s:s}", + "error", &error, + "code", &code)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed GET /refund, error: %s, code: %d\n", diff --git a/src/lib/merchant_api_tip_query.c b/src/lib/merchant_api_tip_query.c index 3887390b..0f72482c 100644 --- a/src/lib/merchant_api_tip_query.c +++ b/src/lib/merchant_api_tip_query.c @@ -96,7 +96,7 @@ check_ok (struct TALER_MERCHANT_TipQueryOperation *tqo, TALER_JSON_spec_amount ("amount_authorized", &amount_authorized), TALER_JSON_spec_amount ("amount_available", &amount_available), TALER_JSON_spec_amount ("amount_picked_up", &amount_picked_up), - GNUNET_JSON_spec_end() + GNUNET_JSON_spec_end () }; if (GNUNET_OK != @@ -130,8 +130,8 @@ check_ok (struct TALER_MERCHANT_TipQueryOperation *tqo, */ static void handle_tip_query_finished (void *cls, - long response_code, - const void *response) + long response_code, + const void *response) { struct TALER_MERCHANT_TipQueryOperation *tqo = cls; const json_t *json = response; diff --git a/src/lib/merchant_api_track_transaction.c b/src/lib/merchant_api_track_transaction.c index e5cac2bb..e2889b38 100644 --- a/src/lib/merchant_api_track_transaction.c +++ b/src/lib/merchant_api_track_transaction.c @@ -123,7 +123,7 @@ handle_track_transaction_finished (void *cls, } tdo->cb (tdo->cb_cls, response_code, - TALER_JSON_get_error_code (json), + TALER_JSON_get_error_code (json), json); TALER_MERCHANT_track_transaction_cancel (tdo); } @@ -143,7 +143,8 @@ struct TALER_MERCHANT_TrackTransactionHandle * TALER_MERCHANT_track_transaction (struct GNUNET_CURL_Context *ctx, const char *backend_url, const char *order_id, - TALER_MERCHANT_TrackTransactionCallback track_transaction_cb, + TALER_MERCHANT_TrackTransactionCallback + track_transaction_cb, void *track_transaction_cb_cls) { struct TALER_MERCHANT_TrackTransactionHandle *tdo; @@ -179,7 +180,9 @@ TALER_MERCHANT_track_transaction (struct GNUNET_CURL_Context *ctx, * @param tdo handle to the tracking operation being cancelled */ void -TALER_MERCHANT_track_transaction_cancel (struct TALER_MERCHANT_TrackTransactionHandle *tdo) +TALER_MERCHANT_track_transaction_cancel (struct + TALER_MERCHANT_TrackTransactionHandle * + tdo) { if (NULL != tdo->job) { diff --git a/src/lib/test_merchant_api.c b/src/lib/test_merchant_api.c index 573d06c4..bb7d9e26 100644 --- a/src/lib/test_merchant_api.c +++ b/src/lib/test_merchant_api.c @@ -164,10 +164,11 @@ intern (const char *str) if (NULL != hs) return hs; hs = GNUNET_strdup (str); - GNUNET_assert (GNUNET_OK == GNUNET_CONTAINER_multihashmap_put (interned_strings, - &hash, - (void *) hs, - GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); + GNUNET_assert (GNUNET_OK == GNUNET_CONTAINER_multihashmap_put ( + interned_strings, + &hash, + (void *) hs, + GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); return hs; } @@ -181,7 +182,8 @@ merchant_url_internal (const char *instance_id) if (NULL == instance_id) GNUNET_assert (0 < snprintf (buf, BUF_SZ, "%s", merchant_url)); else - GNUNET_assert (0 < snprintf (buf, BUF_SZ, "%sinstances/%s/", merchant_url, instance_id)); + GNUNET_assert (0 < snprintf (buf, BUF_SZ, "%sinstances/%s/", merchant_url, + instance_id)); return intern (buf); } @@ -193,7 +195,8 @@ merchant_url_external (const char *instance_id) if (NULL == instance_id) GNUNET_assert (0 < snprintf (buf, BUF_SZ, "%spublic/", merchant_url)); else - GNUNET_assert (0 < snprintf (buf, BUF_SZ, "%spublic/instances/%s/", merchant_url, instance_id)); + GNUNET_assert (0 < snprintf (buf, BUF_SZ, "%spublic/instances/%s/", + merchant_url, instance_id)); return intern (buf); } @@ -777,7 +780,7 @@ run (void *cls, TALER_TESTING_cmd_tip_pickup_with_ec ("pickup-tip-3-too-much", - merchant_url_external ("tip"), + merchant_url_external ("tip"), MHD_HTTP_CONFLICT, "authorize-tip-1", pickup_amounts_1, diff --git a/src/lib/test_merchant_api_twisted.c b/src/lib/test_merchant_api_twisted.c index 901823f4..46fdb47b 100644 --- a/src/lib/test_merchant_api_twisted.c +++ b/src/lib/test_merchant_api_twisted.c @@ -152,7 +152,7 @@ static struct GNUNET_OS_Process *twistermerchantd; * @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 @@ -161,7 +161,7 @@ static struct GNUNET_OS_Process *twistermerchantd; * @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 @@ -172,9 +172,11 @@ static struct GNUNET_OS_Process *twistermerchantd; * @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 @@ -184,10 +186,10 @@ static struct GNUNET_OS_Process *twistermerchantd; * @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 @@ -216,10 +218,10 @@ run (void *cls, TALER_TESTING_cmd_check_bank_transfer ("5719-check-transfer", - EXCHANGE_URL, - "EUR:1.01", - USER_ACCOUNT_NO, - EXCHANGE_ACCOUNT_NO), + EXCHANGE_URL, + "EUR:1.01", + USER_ACCOUNT_NO, + EXCHANGE_ACCOUNT_NO), TALER_TESTING_cmd_withdraw_amount ("5719-withdraw", "5719-create-reserve", @@ -232,9 +234,9 @@ run (void *cls, MHD_HTTP_OK), TALER_TESTING_cmd_proposal ("5719-create-proposal", - twister_merchant_url, - MHD_HTTP_OK, - "{\"max_fee\":\ + twister_merchant_url, + MHD_HTTP_OK, + "{\"max_fee\":\ {\"currency\":\"EUR\",\ \"value\":0,\ \"fraction\":50000000},\ @@ -259,7 +261,7 @@ run (void *cls, */ TALER_TESTING_cmd_malform_response ("5719-malform-xcg-resp", - PROXY_EXCHANGE_CONFIG_FILE), + PROXY_EXCHANGE_CONFIG_FILE), TALER_TESTING_cmd_pay ("5719-deposit", twister_merchant_url, @@ -271,16 +273,16 @@ run (void *cls, "EUR:0.01"), // no sense now TALER_TESTING_cmd_end () }; - + /**** Covering /check-payment ****/ struct TALER_TESTING_Command check_payment[] = { TALER_TESTING_cmd_proposal ("proposal-for-check-payment", - twister_merchant_url, - MHD_HTTP_OK, - "{\"max_fee\":\ + twister_merchant_url, + MHD_HTTP_OK, + "{\"max_fee\":\ {\"currency\":\"EUR\",\ \"value\":0,\ \"fraction\":50000000},\ @@ -299,38 +301,38 @@ run (void *cls, /* Need any response code != 200. */ TALER_TESTING_cmd_hack_response_code ("non-200-response-code", - PROXY_MERCHANT_CONFIG_FILE, - MHD_HTTP_MULTIPLE_CHOICES), + PROXY_MERCHANT_CONFIG_FILE, + MHD_HTTP_MULTIPLE_CHOICES), TALER_TESTING_cmd_check_payment ("check-payment-fail", - twister_merchant_url, - MHD_HTTP_MULTIPLE_CHOICES, - "proposal-for-check-payment", - GNUNET_SYSERR), // any response != 200 gives "syserr" + twister_merchant_url, + MHD_HTTP_MULTIPLE_CHOICES, + "proposal-for-check-payment", + GNUNET_SYSERR), // any response != 200 gives "syserr" TALER_TESTING_cmd_delete_object ("hack-check-payment-0", PROXY_MERCHANT_CONFIG_FILE, "taler_pay_uri"), TALER_TESTING_cmd_check_payment ("check-payment-fail-invalid", - twister_merchant_url, - 0, - "proposal-for-check-payment", - GNUNET_SYSERR), + twister_merchant_url, + 0, + "proposal-for-check-payment", + GNUNET_SYSERR), TALER_TESTING_cmd_modify_object_dl ("paid-true-for-unpaid", - PROXY_MERCHANT_CONFIG_FILE, - "paid", - "true"), + PROXY_MERCHANT_CONFIG_FILE, + "paid", + "true"), TALER_TESTING_cmd_check_payment ("check-payment-fail-invalid-0", - twister_merchant_url, - 0, - "proposal-for-check-payment", - GNUNET_SYSERR), + twister_merchant_url, + 0, + "proposal-for-check-payment", + GNUNET_SYSERR), TALER_TESTING_cmd_end () }; @@ -344,31 +346,31 @@ run (void *cls, */ TALER_TESTING_cmd_malform_request ("malform-order", - PROXY_MERCHANT_CONFIG_FILE), - + PROXY_MERCHANT_CONFIG_FILE), + TALER_TESTING_cmd_proposal ("create-proposal-0", - twister_merchant_url, - MHD_HTTP_BAD_REQUEST, - /* giving a valid JSON to not make it fail before - * data reaches the merchant. */ - "{\"not\": \"used\"}"), - + twister_merchant_url, + MHD_HTTP_BAD_REQUEST, + /* giving a valid JSON to not make it fail before + * data reaches the merchant. */ + "{\"not\": \"used\"}"), + TALER_TESTING_cmd_hack_response_code ("proposal-500", - PROXY_MERCHANT_CONFIG_FILE, - MHD_HTTP_INTERNAL_SERVER_ERROR), - + PROXY_MERCHANT_CONFIG_FILE, + MHD_HTTP_INTERNAL_SERVER_ERROR), + TALER_TESTING_cmd_proposal ("create-proposal-1", - twister_merchant_url, - /* This status code == 0 is gotten via a 500 Internal Server - * Error handed to the library. */ - MHD_HTTP_INTERNAL_SERVER_ERROR, - /* giving a valid JSON to not make it fail before - * data reaches the merchant. */ - "{\"not\": \"used\"}"), - + twister_merchant_url, + /* This status code == 0 is gotten via a 500 Internal Server + * Error handed to the library. */ + MHD_HTTP_INTERNAL_SERVER_ERROR, + /* giving a valid JSON to not make it fail before + * data reaches the merchant. */ + "{\"not\": \"used\"}"), + /** * Cause the PUT /proposal callback to be called * with a response code == 0. We achieve this by malforming @@ -377,13 +379,13 @@ run (void *cls, TALER_TESTING_cmd_malform_response ("malform-proposal", - PROXY_MERCHANT_CONFIG_FILE), + PROXY_MERCHANT_CONFIG_FILE), TALER_TESTING_cmd_proposal ("create-proposal-2", - twister_merchant_url, - 0, - "{\"max_fee\":\ + twister_merchant_url, + 0, + "{\"max_fee\":\ {\"currency\":\"EUR\",\ \"value\":0,\ \"fraction\":50000000},\ @@ -406,9 +408,9 @@ run (void *cls, "order_id"), TALER_TESTING_cmd_proposal ("create-proposal-3", - twister_merchant_url, - 0, - "{\"max_fee\":\ + twister_merchant_url, + 0, + "{\"max_fee\":\ {\"currency\":\"EUR\",\ \"value\":0,\ \"fraction\":50000000},\ @@ -429,9 +431,9 @@ run (void *cls, */ TALER_TESTING_cmd_proposal ("create-proposal-4", - twister_merchant_url_instance_nonexistent, - MHD_HTTP_NOT_FOUND, - "{\"amount\":\"EUR:5\",\ + twister_merchant_url_instance_nonexistent, + MHD_HTTP_NOT_FOUND, + "{\"amount\":\"EUR:5\",\ \"fulfillment_url\": \"https://example.com/\",\ \"summary\": \"merchant-lib testcase\"}"), @@ -445,7 +447,7 @@ run (void *cls, /* Cause a unparsable response to be returned. */ TALER_TESTING_cmd_malform_response ("malform-proposal-lookup", - PROXY_MERCHANT_CONFIG_FILE), + PROXY_MERCHANT_CONFIG_FILE), /* To be short, we'll make a _error_ response to be * unparsable. */ TALER_TESTING_cmd_proposal_lookup ("lookup-1", @@ -463,9 +465,9 @@ run (void *cls, * we can lookup for it later. */ TALER_TESTING_cmd_proposal ("create-proposal-5", - twister_merchant_url, - MHD_HTTP_OK, - "{\"max_fee\":\ + twister_merchant_url, + MHD_HTTP_OK, + "{\"max_fee\":\ {\"currency\":\"EUR\",\ \"value\":0,\ \"fraction\":50000000},\ @@ -496,7 +498,7 @@ run (void *cls, TALER_TESTING_cmd_end () }; - /**** Covering /history lib ****/ + /**** Covering /history lib ****/ struct TALER_TESTING_Command history[] = { /** @@ -508,8 +510,8 @@ run (void *cls, */ TALER_TESTING_cmd_hack_response_code ("twist-history", - PROXY_MERCHANT_CONFIG_FILE, - MHD_HTTP_GONE), + PROXY_MERCHANT_CONFIG_FILE, + MHD_HTTP_GONE), TALER_TESTING_cmd_history ("history-0", twister_merchant_url, @@ -525,7 +527,7 @@ run (void *cls, */ TALER_TESTING_cmd_malform_response ("malform-history", - PROXY_MERCHANT_CONFIG_FILE), + PROXY_MERCHANT_CONFIG_FILE), TALER_TESTING_cmd_history ("history-1", twister_merchant_url, @@ -548,36 +550,36 @@ run (void *cls, CMD_TRANSFER_TO_EXCHANGE ("create-reserve-unaggregation", - "EUR:5.01"), + "EUR:5.01"), CMD_EXEC_WIREWATCH ("wirewatch-unaggregation"), TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-unaggregation", - EXCHANGE_URL, - "EUR:5.01", - USER_ACCOUNT_NO, - EXCHANGE_ACCOUNT_NO), + EXCHANGE_URL, + "EUR:5.01", + USER_ACCOUNT_NO, + EXCHANGE_ACCOUNT_NO), TALER_TESTING_cmd_check_bank_empty ("check_bank_unaggregated-a"), TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-unaggregation", - "create-reserve-unaggregation", - "EUR:5", - MHD_HTTP_OK), + "create-reserve-unaggregation", + "EUR:5", + MHD_HTTP_OK), TALER_TESTING_cmd_proposal ("create-proposal-unaggregation", - /* Need a fresh instance in order to associate this - * proposal with a fresh h_wire; this way, this proposal - * won't get hooked by the aggregator gathering same-H_wire'd - * transactions. */ - twister_merchant_url_instance_tor, - MHD_HTTP_OK, - "{\"max_fee\":\ + /* Need a fresh instance in order to associate this + * proposal with a fresh h_wire; this way, this proposal + * won't get hooked by the aggregator gathering same-H_wire'd + * transactions. */ + twister_merchant_url_instance_tor, + MHD_HTTP_OK, + "{\"max_fee\":\ {\"currency\":\"EUR\",\ \"value\":0,\ \"fraction\":50000000},\ @@ -595,13 +597,13 @@ run (void *cls, TALER_TESTING_cmd_pay ("pay-unaggregation", - merchant_url, - MHD_HTTP_OK, - "create-proposal-unaggregation", - "withdraw-coin-unaggregation", - "EUR:5", // amount + fee - "EUR:4.99", // amount - fee - "EUR:0.01"), // refund fee + merchant_url, + MHD_HTTP_OK, + "create-proposal-unaggregation", + "withdraw-coin-unaggregation", + "EUR:5", // amount + fee + "EUR:4.99", // amount - fee + "EUR:0.01"), // refund fee CMD_EXEC_AGGREGATOR ("aggregation-attempt"), @@ -620,25 +622,25 @@ run (void *cls, CMD_EXEC_WIREWATCH ("wirewatch-5383"), TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-5383", - EXCHANGE_URL, - "EUR:2.02", - USER_ACCOUNT_NO, - EXCHANGE_ACCOUNT_NO), + EXCHANGE_URL, + "EUR:2.02", + USER_ACCOUNT_NO, + EXCHANGE_ACCOUNT_NO), TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-5383a", - "create-reserve-5383", - "EUR:1", - MHD_HTTP_OK), + "create-reserve-5383", + "EUR:1", + MHD_HTTP_OK), TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-5383b", - "create-reserve-5383", - "EUR:1", - MHD_HTTP_OK), + "create-reserve-5383", + "EUR:1", + MHD_HTTP_OK), TALER_TESTING_cmd_proposal ("create-proposal-5383", - twister_merchant_url, - MHD_HTTP_OK, - "{\"max_fee\":\ + twister_merchant_url, + MHD_HTTP_OK, + "{\"max_fee\":\ {\"currency\":\"EUR\",\ \"value\":0,\ \"fraction\":50000000},\ @@ -665,25 +667,25 @@ run (void *cls, CMD_EXEC_AGGREGATOR ("run-aggregator-5383"), TALER_TESTING_cmd_check_bank_transfer ("check_aggregation_transfer-5383", - twister_exchange_url, /* has the 8888-port thing. */ - /* paid, 1.97 = - brutto 2.00 - - deposit fee 0.01 * 2 - - wire fee 0.01 - */ - "EUR:1.97", - EXCHANGE_ACCOUNT_NO, - MERCHANT_ACCOUNT_NO), + twister_exchange_url, /* has the 8888-port thing. */ + /* paid, 1.97 = + brutto 2.00 - + deposit fee 0.01 * 2 - + wire fee 0.01 + */ + "EUR:1.97", + EXCHANGE_ACCOUNT_NO, + MERCHANT_ACCOUNT_NO), TALER_TESTING_cmd_modify_object_dl ("hack-5383", - PROXY_EXCHANGE_CONFIG_FILE, - "total", - "EUR:0.98"), + PROXY_EXCHANGE_CONFIG_FILE, + "total", + "EUR:0.98"), TALER_TESTING_cmd_merchant_track_transfer ("track-5383", - twister_merchant_url, - MHD_HTTP_FAILED_DEPENDENCY, - "check_aggregation_transfer-5383"), + twister_merchant_url, + MHD_HTTP_FAILED_DEPENDENCY, + "check_aggregation_transfer-5383"), TALER_TESTING_cmd_end () }; @@ -706,8 +708,8 @@ run (void *cls, TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-2", - EXCHANGE_URL, - "EUR:2.02", USER_ACCOUNT_NO, EXCHANGE_ACCOUNT_NO), + EXCHANGE_URL, + "EUR:2.02", USER_ACCOUNT_NO, EXCHANGE_ACCOUNT_NO), TALER_TESTING_cmd_check_bank_empty ("track_chunk_check_empty-a"), @@ -727,9 +729,9 @@ run (void *cls, TALER_TESTING_cmd_proposal ("create-proposal-6", - twister_merchant_url, - MHD_HTTP_OK, - "{\"max_fee\":\ + twister_merchant_url, + MHD_HTTP_OK, + "{\"max_fee\":\ {\"currency\":\"EUR\",\ \"value\":0,\ \"fraction\":50000000},\ @@ -769,15 +771,15 @@ run (void *cls, CMD_EXEC_AGGREGATOR ("run-aggregator"), TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-1", - twister_exchange_url, /* has the 8888-port thing. */ - /* paid, 1.97 = - brutto 2.00 - - deposit fee 0.01 * 2 - - wire fee 0.01 - */ - "EUR:1.97", - EXCHANGE_ACCOUNT_NO, - MERCHANT_ACCOUNT_NO), + twister_exchange_url, /* has the 8888-port thing. */ + /* paid, 1.97 = + brutto 2.00 - + deposit fee 0.01 * 2 - + wire fee 0.01 + */ + "EUR:1.97", + EXCHANGE_ACCOUNT_NO, + MERCHANT_ACCOUNT_NO), /** * Fake total to include only one coin. Math: each 1-EUR @@ -795,18 +797,18 @@ run (void *cls, * issued below by the test case (to the merchant backend.) */ TALER_TESTING_cmd_modify_object_dl ("hack-0", - PROXY_EXCHANGE_CONFIG_FILE, - "total", - "EUR:0.98"), + PROXY_EXCHANGE_CONFIG_FILE, + "total", + "EUR:0.98"), TALER_TESTING_cmd_delete_object ("hack-1", - PROXY_EXCHANGE_CONFIG_FILE, - "deposits.0"), + PROXY_EXCHANGE_CONFIG_FILE, + "deposits.0"), TALER_TESTING_cmd_merchant_track_transaction ("track-transaction-1", - twister_merchant_url, - MHD_HTTP_FAILED_DEPENDENCY, - "deposit-simple"), + twister_merchant_url, + MHD_HTTP_FAILED_DEPENDENCY, + "deposit-simple"), TALER_TESTING_cmd_end () }; @@ -829,8 +831,8 @@ run (void *cls, TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-abort-1", - EXCHANGE_URL, - "EUR:1.01", USER_ACCOUNT_NO, EXCHANGE_ACCOUNT_NO), + EXCHANGE_URL, + "EUR:1.01", USER_ACCOUNT_NO, EXCHANGE_ACCOUNT_NO), TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-abort-1", "create-reserve-abort-1", @@ -844,9 +846,9 @@ run (void *cls, TALER_TESTING_cmd_proposal ("create-proposal-abort-1", - twister_merchant_url, - MHD_HTTP_OK, - "{\"max_fee\":\ + twister_merchant_url, + MHD_HTTP_OK, + "{\"max_fee\":\ {\"currency\":\"EUR\",\ \"value\":0,\ \"fraction\":50000000},\ @@ -884,8 +886,8 @@ run (void *cls, TALER_TESTING_cmd_delete_object ("hack-abort-2", - PROXY_MERCHANT_CONFIG_FILE, - "refund_permissions.0.rtransaction_id"), + PROXY_MERCHANT_CONFIG_FILE, + "refund_permissions.0.rtransaction_id"), TALER_TESTING_cmd_pay_abort ("pay-abort-2", twister_merchant_url, @@ -894,10 +896,10 @@ run (void *cls, TALER_TESTING_cmd_modify_object_dl ("hack-abort-3", - PROXY_MERCHANT_CONFIG_FILE, - "refund_permissions.0.coin_pub", - /* dummy coin. */ - "8YX10E41ZWHX0X2RK4XFAXB2D3M05M1HNG14ZFZZB8M7SA4QCKCG"), + PROXY_MERCHANT_CONFIG_FILE, + "refund_permissions.0.coin_pub", + /* dummy coin. */ + "8YX10E41ZWHX0X2RK4XFAXB2D3M05M1HNG14ZFZZB8M7SA4QCKCG"), TALER_TESTING_cmd_pay_abort ("pay-abort-3", twister_merchant_url, @@ -906,8 +908,8 @@ run (void *cls, TALER_TESTING_cmd_flip_download ("hack-abort-4", - PROXY_MERCHANT_CONFIG_FILE, - "refund_permissions.0.merchant_sig"), + PROXY_MERCHANT_CONFIG_FILE, + "refund_permissions.0.merchant_sig"), TALER_TESTING_cmd_pay_abort ("pay-abort-4", twister_merchant_url, @@ -916,7 +918,7 @@ run (void *cls, /* just malforming the response. */ TALER_TESTING_cmd_malform_response ("malform-abortion", - PROXY_MERCHANT_CONFIG_FILE), + PROXY_MERCHANT_CONFIG_FILE), TALER_TESTING_cmd_pay_abort ("pay-abort-5", twister_merchant_url, @@ -930,9 +932,9 @@ run (void *cls, TALER_TESTING_cmd_proposal ("create-proposal-double-spend", - twister_merchant_url, - MHD_HTTP_OK, - "{\"max_fee\":\ + twister_merchant_url, + MHD_HTTP_OK, + "{\"max_fee\":\ {\"currency\":\"EUR\",\ \"value\":0,\ \"fraction\":50000000},\ @@ -949,9 +951,9 @@ run (void *cls, TALER_TESTING_cmd_proposal ("create-proposal-double-spend-1", - twister_merchant_url, - MHD_HTTP_OK, - "{\"max_fee\":\ + twister_merchant_url, + MHD_HTTP_OK, + "{\"max_fee\":\ {\"currency\":\"EUR\",\ \"value\":0,\ \"fraction\":50000000},\ @@ -968,9 +970,9 @@ run (void *cls, TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-double-spend", - "create-reserve-double-spend", - "EUR:1", - MHD_HTTP_OK), + "create-reserve-double-spend", + "EUR:1", + MHD_HTTP_OK), TALER_TESTING_cmd_pay ("deposit-simple-ok", twister_merchant_url, @@ -983,8 +985,8 @@ run (void *cls, TALER_TESTING_cmd_flip_download ("hack-coin-history", - PROXY_MERCHANT_CONFIG_FILE, - "history.0.coin_sig"), + PROXY_MERCHANT_CONFIG_FILE, + "history.0.coin_sig"), /* Coin history check will fail, * due to coin's bad signature. */ @@ -1056,7 +1058,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... */ @@ -1066,24 +1068,26 @@ main (int argc, "DEBUG", NULL); if (NULL == (fakebank_url = TALER_TESTING_prepare_fakebank - (CONFIG_FILE, - "account-exchange"))) + (CONFIG_FILE, + "account-exchange"))) return 77; if (NULL == (merchant_url = TALER_TESTING_prepare_merchant - (CONFIG_FILE))) + (CONFIG_FILE))) return 77; if (NULL == (twister_exchange_url = TALER_TESTING_prepare_twister - (PROXY_EXCHANGE_CONFIG_FILE))) + (PROXY_EXCHANGE_CONFIG_FILE))) return 77; if (NULL == (twister_merchant_url = TALER_TESTING_prepare_twister - (PROXY_MERCHANT_CONFIG_FILE))) + (PROXY_MERCHANT_CONFIG_FILE))) return 77; - twister_merchant_url_instance_nonexistent = TALER_url_join (twister_exchange_url, "instances/foo/", NULL); - twister_merchant_url_instance_tor = TALER_url_join (twister_exchange_url, "instances/tor/", NULL); + twister_merchant_url_instance_nonexistent = TALER_url_join ( + twister_exchange_url, "instances/foo/", NULL); + twister_merchant_url_instance_tor = TALER_url_join (twister_exchange_url, + "instances/tor/", NULL); TALER_TESTING_cleanup_files (CONFIG_FILE); @@ -1100,16 +1104,16 @@ main (int argc, case GNUNET_OK: if (NULL == (merchantd = TALER_TESTING_run_merchant - (CONFIG_FILE, merchant_url))) + (CONFIG_FILE, merchant_url))) // 1 is fine; after all this is merchant test cases. return 1; if (NULL == (twisterexchanged = TALER_TESTING_run_twister - (PROXY_EXCHANGE_CONFIG_FILE))) + (PROXY_EXCHANGE_CONFIG_FILE))) return 77; if (NULL == (twistermerchantd = TALER_TESTING_run_twister - (PROXY_MERCHANT_CONFIG_FILE))) + (PROXY_MERCHANT_CONFIG_FILE))) return 77; /* Run the exchange and schedule 'run()' */ diff --git a/src/lib/testing_api_cmd_history.c b/src/lib/testing_api_cmd_history.c index 6704fb93..fc1b269f 100644 --- a/src/lib/testing_api_cmd_history.c +++ b/src/lib/testing_api_cmd_history.c @@ -164,7 +164,7 @@ history_cb (void *cls, hs->ho = NULL; if (hs->http_status != http_status) - TALER_TESTING_FAIL (hs->is); + TALER_TESTING_FAIL (hs->is); if (0 == hs->http_status) { @@ -256,24 +256,24 @@ history_run (void *cls, if (0 == hs->time.abs_value_us) { hs->time = GNUNET_TIME_absolute_add - (GNUNET_TIME_absolute_get (), - GNUNET_TIME_UNIT_HOURS); + (GNUNET_TIME_absolute_get (), + GNUNET_TIME_UNIT_HOURS); GNUNET_TIME_round_abs (&hs->time); } switch (hs->use_default_start) { - case GNUNET_YES: + case GNUNET_YES: hs->ho = TALER_MERCHANT_history_default_start - (is->ctx, - hs->merchant_url, - hs->nrows, - hs->time, - &history_cb, - hs); + (is->ctx, + hs->merchant_url, + hs->nrows, + hs->time, + &history_cb, + hs); break; - case GNUNET_NO: + case GNUNET_NO: hs->ho = TALER_MERCHANT_history (is->ctx, hs->merchant_url, hs->start, @@ -282,9 +282,9 @@ history_run (void *cls, &history_cb, hs); break; - default: - TALER_LOG_ERROR ("Bad value for 'use_default_start'\n"); - TALER_TESTING_FAIL (is); + default: + TALER_LOG_ERROR ("Bad value for 'use_default_start'\n"); + TALER_TESTING_FAIL (is); } if (NULL == hs->ho) @@ -357,11 +357,11 @@ cmd_history2 (const char *label, struct TALER_TESTING_Command TALER_TESTING_cmd_history_default_start (const char *label, - const char *merchant_url, - unsigned int http_status, - struct GNUNET_TIME_Absolute time, - unsigned int nresult, - long long nrows) + const char *merchant_url, + unsigned int http_status, + struct GNUNET_TIME_Absolute time, + unsigned int nresult, + long long nrows) { return cmd_history2 (label, merchant_url, diff --git a/src/lib/testing_api_cmd_refund.c b/src/lib/testing_api_cmd_refund.c index f0ee31b5..9bd30cc7 100644 --- a/src/lib/testing_api_cmd_refund.c +++ b/src/lib/testing_api_cmd_refund.c @@ -299,7 +299,7 @@ refund_lookup_cb (void *cls, { struct TALER_CoinSpendPublicKeyP coin_pub; struct TALER_Amount *irefund_amount = GNUNET_new - (struct TALER_Amount); + (struct TALER_Amount); struct GNUNET_JSON_Specification spec[] = { GNUNET_JSON_spec_fixed_auto ("coin_pub", &coin_pub), TALER_JSON_spec_amount ("refund_amount", irefund_amount), @@ -307,28 +307,28 @@ refund_lookup_cb (void *cls, }; GNUNET_assert (GNUNET_OK == GNUNET_JSON_parse (elem, - spec, + spec, &error_name, &error_line)); GNUNET_CRYPTO_hash (&coin_pub, - sizeof (struct TALER_CoinSpendPublicKeyP), - &h_coin_pub); + sizeof (struct TALER_CoinSpendPublicKeyP), + &h_coin_pub); GNUNET_assert (GNUNET_OK == GNUNET_CONTAINER_multihashmap_put - (map, - &h_coin_pub, // which - irefund_amount, // how much - GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); + (map, + &h_coin_pub, // which + irefund_amount, // how much + GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); }; /* Compare spent coins with refunded, and if they match, * increase an accumulator. */ if ( NULL == - ( pay_cmd = TALER_TESTING_interpreter_lookup_command - (rls->is, rls->pay_reference))) + (pay_cmd = TALER_TESTING_interpreter_lookup_command + (rls->is, rls->pay_reference))) TALER_TESTING_FAIL (rls->is); if (GNUNET_OK != TALER_TESTING_get_trait_coin_reference - (pay_cmd, 0, &coin_reference)) + (pay_cmd, 0, &coin_reference)) TALER_TESTING_FAIL (rls->is); GNUNET_assert (GNUNET_OK == TALER_amount_get_zero ("EUR", @@ -345,8 +345,8 @@ refund_lookup_cb (void *cls, const struct TALER_TESTING_Command *icoin_cmd; if ( NULL == - ( icoin_cmd = TALER_TESTING_interpreter_lookup_command - (rls->is, icoin_reference)) ) + (icoin_cmd = TALER_TESTING_interpreter_lookup_command + (rls->is, icoin_reference)) ) { GNUNET_break (0); TALER_LOG_ERROR ("Bad reference `%s'\n", @@ -356,16 +356,16 @@ refund_lookup_cb (void *cls, return; } - if (GNUNET_OK != TALER_TESTING_get_trait_coin_priv - (icoin_cmd, 0, &icoin_priv)) - { - GNUNET_break (0); - TALER_LOG_ERROR ("Command `%s' failed to give coin" - " priv trait\n", - icoin_reference); - TALER_TESTING_interpreter_fail (rls->is); - GNUNET_CONTAINER_multihashmap_destroy (map); - return; + if (GNUNET_OK != TALER_TESTING_get_trait_coin_priv + (icoin_cmd, 0, &icoin_priv)) + { + GNUNET_break (0); + TALER_LOG_ERROR ("Command `%s' failed to give coin" + " priv trait\n", + icoin_reference); + TALER_TESTING_interpreter_fail (rls->is); + GNUNET_CONTAINER_multihashmap_destroy (map); + return; } GNUNET_CRYPTO_eddsa_key_get_public (&icoin_priv->eddsa_priv, @@ -375,7 +375,7 @@ refund_lookup_cb (void *cls, &h_icoin_pub); iamount = GNUNET_CONTAINER_multihashmap_get - (map, &h_icoin_pub); + (map, &h_icoin_pub); /* Can be NULL: not all coins are involved in refund */ if (NULL == iamount) @@ -389,15 +389,15 @@ refund_lookup_cb (void *cls, GNUNET_free (coin_reference_dup); if (NULL != - (increase_cmd = TALER_TESTING_interpreter_lookup_command - (rls->is, rls->increase_reference))) + (increase_cmd = TALER_TESTING_interpreter_lookup_command + (rls->is, rls->increase_reference))) { if (GNUNET_OK != TALER_TESTING_get_trait_amount - (increase_cmd, 0, &refund_amount)) + (increase_cmd, 0, &refund_amount)) TALER_TESTING_FAIL (rls->is); if (GNUNET_OK != TALER_string_to_amount - (refund_amount, &ra)) + (refund_amount, &ra)) TALER_TESTING_FAIL (rls->is); } else @@ -405,7 +405,7 @@ refund_lookup_cb (void *cls, GNUNET_assert (NULL != rls->refund_amount); if (GNUNET_OK != TALER_string_to_amount - (rls->refund_amount, &ra)) + (rls->refund_amount, &ra)) TALER_TESTING_FAIL (rls->is); } @@ -503,12 +503,12 @@ refund_increase_traits (void *cls, struct TALER_TESTING_Command TALER_TESTING_cmd_refund_increase (const char *label, - const char *merchant_url, - const char *reason, - const char *order_id, - const char *refund_amount, - const char *refund_fee, - unsigned int http_code) + const char *merchant_url, + const char *reason, + const char *order_id, + const char *refund_amount, + const char *refund_fee, + unsigned int http_code) { struct RefundIncreaseState *ris; @@ -551,11 +551,11 @@ TALER_TESTING_cmd_refund_increase struct TALER_TESTING_Command TALER_TESTING_cmd_refund_lookup (const char *label, - const char *merchant_url, - const char *increase_reference, - const char *pay_reference, - const char *order_id, - unsigned int http_code) + const char *merchant_url, + const char *increase_reference, + const char *pay_reference, + const char *order_id, + unsigned int http_code) { struct RefundLookupState *rls; @@ -601,12 +601,12 @@ TALER_TESTING_cmd_refund_lookup struct TALER_TESTING_Command TALER_TESTING_cmd_refund_lookup_with_amount (const char *label, - const char *merchant_url, - const char *increase_reference, - const char *pay_reference, - const char *order_id, - unsigned int http_code, - const char *refund_amount) + const char *merchant_url, + const char *increase_reference, + const char *pay_reference, + const char *order_id, + unsigned int http_code, + const char *refund_amount) { struct RefundLookupState *rls; diff --git a/src/lib/testing_api_cmd_rewind.c b/src/lib/testing_api_cmd_rewind.c index 2b65a70e..ba694b8c 100644 --- a/src/lib/testing_api_cmd_rewind.c +++ b/src/lib/testing_api_cmd_rewind.c @@ -56,7 +56,8 @@ struct RewindIpState static void rewind_ip_cleanup (void *cls, const struct TALER_TESTING_Command *cmd) -{} +{ +} /** @@ -76,7 +77,7 @@ rewind_ip_run (void *cls, if (1 < *ris->counter) { is->ip = ris->new_ip; - *ris->counter -= 1; + *ris->counter -= 1; } TALER_TESTING_interpreter_next (is); @@ -98,8 +99,8 @@ rewind_ip_run (void *cls, struct TALER_TESTING_Command TALER_TESTING_cmd_rewind_ip (const char *label, - int new_ip, - unsigned int *counter) + int new_ip, + unsigned int *counter) { struct RewindIpState *ris; diff --git a/src/lib/testing_api_cmd_tip.c b/src/lib/testing_api_cmd_tip.c index a5bbf2a1..77ab919e 100644 --- a/src/lib/testing_api_cmd_tip.c +++ b/src/lib/testing_api_cmd_tip.c @@ -330,14 +330,14 @@ tip_authorize_run (void *cls, TALER_TESTING_FAIL (is); tas->tao = TALER_MERCHANT_tip_authorize - (is->ctx, - tas->merchant_url, - "http://merchant.com/pickup", - "http://merchant.com/continue", - &amount, - tas->justification, - tip_authorize_cb, - tas); + (is->ctx, + tas->merchant_url, + "http://merchant.com/pickup", + "http://merchant.com/continue", + &amount, + tas->justification, + tip_authorize_cb, + tas); GNUNET_assert (NULL != tas->tao); } @@ -408,12 +408,12 @@ tip_authorize_cleanup (void *cls, struct TALER_TESTING_Command TALER_TESTING_cmd_tip_authorize_with_ec (const char *label, - const char *merchant_url, - const char *exchange_url, - unsigned int http_status, - const char *justification, - const char *amount, - enum TALER_ErrorCode ec) + const char *merchant_url, + const char *exchange_url, + unsigned int http_status, + const char *justification, + const char *amount, + enum TALER_ErrorCode ec) { struct TipAuthorizeState *tas; @@ -522,7 +522,7 @@ tip_query_cb (void *cls, if (tqs->expected_amount_available) { GNUNET_assert (GNUNET_OK == TALER_string_to_amount - (tqs->expected_amount_available, &a)); + (tqs->expected_amount_available, &a)); { char *str; @@ -539,7 +539,7 @@ tip_query_cb (void *cls, if (tqs->expected_amount_authorized) { GNUNET_assert (GNUNET_OK == TALER_string_to_amount - (tqs->expected_amount_authorized, &a)); + (tqs->expected_amount_authorized, &a)); { char *str; @@ -556,7 +556,7 @@ tip_query_cb (void *cls, if (tqs->expected_amount_picked_up) { GNUNET_assert (GNUNET_OK == TALER_string_to_amount - (tqs->expected_amount_picked_up, &a)); + (tqs->expected_amount_picked_up, &a)); { char *str; str = TALER_amount_to_string (amount_picked_up); @@ -639,11 +639,11 @@ tip_query_run (void *cls, struct TALER_TESTING_Command TALER_TESTING_cmd_tip_query_with_amounts (const char *label, - const char *merchant_url, - unsigned int http_status, - const char *expected_amount_picked_up, - const char *expected_amount_authorized, - const char *expected_amount_available) + const char *merchant_url, + unsigned int http_status, + const char *expected_amount_picked_up, + const char *expected_amount_authorized, + const char *expected_amount_available) { struct TipQueryState *tqs; @@ -769,15 +769,16 @@ pickup_withdraw_cb (void *cls, } if (NULL == tps->sigs) tps->sigs = GNUNET_new_array - (tps->num_coins, struct TALER_DenominationSignature); + (tps->num_coins, struct TALER_DenominationSignature); GNUNET_assert (NULL == tps->sigs[wh->off].rsa_signature); tps->sigs[wh->off].rsa_signature = GNUNET_CRYPTO_rsa_signature_dup (sig->rsa_signature); - for (unsigned int i=0; i<tps->num_coins; i++) + for (unsigned int i = 0; i<tps->num_coins; i++) if (NULL != tps->withdraws[wh->off].wsh) - return; /* still some ops ongoing */ + return; + /* still some ops ongoing */ GNUNET_free (tps->withdraws); tps->withdraws = NULL; @@ -846,9 +847,9 @@ pickup_cb (void *cls, GNUNET_assert (NULL == tps->withdraws); tps->withdraws = GNUNET_new_array - (num_reserve_sigs, struct WithdrawHandle); + (num_reserve_sigs, struct WithdrawHandle); - for (unsigned int i=0;i<num_reserve_sigs;i++) + for (unsigned int i = 0; i<num_reserve_sigs; i++) { struct WithdrawHandle *wh = &tps->withdraws[i]; @@ -857,18 +858,18 @@ pickup_cb (void *cls, wh->tps = tps; GNUNET_assert ( (NULL == wh->wsh) && - ( (NULL == tps->sigs) || - (NULL == tps->sigs[wh->off].rsa_signature) ) ); + ( (NULL == tps->sigs) || + (NULL == tps->sigs[wh->off].rsa_signature) ) ); wh->wsh = TALER_EXCHANGE_reserve_withdraw2 - (tps->is->exchange, - tps->dks[i], - &reserve_sigs[i], - reserve_pub, - &tps->psa[i], - &pickup_withdraw_cb, - wh); - if (NULL == wh->wsh) - TALER_TESTING_FAIL (tps->is); + (tps->is->exchange, + tps->dks[i], + &reserve_sigs[i], + reserve_pub, + &tps->psa[i], + &pickup_withdraw_cb, + wh); + if (NULL == wh->wsh) + TALER_TESTING_FAIL (tps->is); } if (0 == num_reserve_sigs) TALER_TESTING_interpreter_next (tps->is); @@ -900,7 +901,7 @@ tip_pickup_run (void *cls, replay_cmd = NULL; /* Count planchets. */ - for (num_planchets=0; + for (num_planchets = 0; NULL != tps->amounts[num_planchets]; num_planchets++); } @@ -908,19 +909,19 @@ tip_pickup_run (void *cls, { const unsigned int *np; if ( NULL == /* looking for "parent" tip-pickup command */ - ( replay_cmd = TALER_TESTING_interpreter_lookup_command - (is, tps->replay_reference)) ) - TALER_TESTING_FAIL (is); + (replay_cmd = TALER_TESTING_interpreter_lookup_command + (is, tps->replay_reference)) ) + TALER_TESTING_FAIL (is); if (GNUNET_OK != TALER_TESTING_get_trait_uint - (replay_cmd, 0, &np)) + (replay_cmd, 0, &np)) TALER_TESTING_FAIL (is); num_planchets = *np; } if (NULL == - ( authorize_cmd = TALER_TESTING_interpreter_lookup_command - (is, tps->authorize_reference)) ) + (authorize_cmd = TALER_TESTING_interpreter_lookup_command + (is, tps->authorize_reference)) ) TALER_TESTING_FAIL (is); tps->num_coins = num_planchets; @@ -930,22 +931,22 @@ tip_pickup_run (void *cls, tps->psa = GNUNET_new_array (num_planchets, struct TALER_PlanchetSecretsP); tps->dks = GNUNET_new_array - (num_planchets, - const struct TALER_EXCHANGE_DenomPublicKey *); + (num_planchets, + const struct TALER_EXCHANGE_DenomPublicKey *); tps->amounts_obj = GNUNET_new_array - (num_planchets, struct TALER_Amount); + (num_planchets, struct TALER_Amount); - for (unsigned int i=0;i<num_planchets;i++) + for (unsigned int i = 0; i<num_planchets; i++) { if (NULL == replay_cmd) { GNUNET_assert (GNUNET_OK == TALER_string_to_amount - (tps->amounts[i], &tps->amounts_obj[i])); + (tps->amounts[i], &tps->amounts_obj[i])); tps->dks[i] = TALER_TESTING_find_pk - (is->keys, - &tps->amounts_obj[i]); + (is->keys, + &tps->amounts_obj[i]); if (NULL == tps->dks[i]) TALER_TESTING_FAIL (is); @@ -955,13 +956,13 @@ tip_pickup_run (void *cls, else { if (GNUNET_OK != TALER_TESTING_get_trait_denom_pub - (replay_cmd, i, &tps->dks[i])) + (replay_cmd, i, &tps->dks[i])) TALER_TESTING_FAIL (is); struct TALER_PlanchetSecretsP *ps; if (GNUNET_OK != TALER_TESTING_get_trait_planchet_secrets - (replay_cmd, i, &ps)) + (replay_cmd, i, &ps)) TALER_TESTING_FAIL (is); tps->psa[i] = *ps; } @@ -973,7 +974,7 @@ tip_pickup_run (void *cls, } if (GNUNET_OK != TALER_TESTING_get_trait_tip_id - (authorize_cmd, 0, &tip_id)) + (authorize_cmd, 0, &tip_id)) TALER_TESTING_FAIL (is); tps->tpo = TALER_MERCHANT_tip_pickup (is->ctx, @@ -983,7 +984,7 @@ tip_pickup_run (void *cls, planchets, &pickup_cb, tps); - for (unsigned int i=0;i<num_planchets;i++) + for (unsigned int i = 0; i<num_planchets; i++) { GNUNET_free (planchets[i].coin_ev); planchets[i].coin_ev = NULL; @@ -1012,7 +1013,7 @@ tip_pickup_cleanup (void *cls, GNUNET_free_non_null (tps->withdraws); if (NULL != tps->sigs) { - for (unsigned int i=0;i<tps->num_coins;i++) + for (unsigned int i = 0; i<tps->num_coins; i++) if (NULL != tps->sigs[i].rsa_signature) GNUNET_CRYPTO_rsa_signature_free (tps->sigs[i].rsa_signature); GNUNET_free (tps->sigs); @@ -1049,10 +1050,10 @@ tip_pickup_traits (void *cls, #define NUM_TRAITS (tps->num_coins * 5) + 2 struct TALER_TESTING_Trait traits[NUM_TRAITS]; - for (unsigned int i=0; i<tps->num_coins; i++) + for (unsigned int i = 0; i<tps->num_coins; i++) { traits[i] = TALER_TESTING_make_trait_planchet_secrets - (i, &tps->psa[i]); + (i, &tps->psa[i]); traits[i + tps->num_coins] = TALER_TESTING_make_trait_coin_priv @@ -1061,16 +1062,16 @@ tip_pickup_traits (void *cls, traits[i + (tps->num_coins * 2)] = TALER_TESTING_make_trait_denom_pub (i, tps->dks[i]); - traits[i + (tps->num_coins *3)] = + traits[i + (tps->num_coins * 3)] = TALER_TESTING_make_trait_denom_sig (i, &tps->sigs[i]); - traits[i + (tps->num_coins *4)] = + traits[i + (tps->num_coins * 4)] = TALER_TESTING_make_trait_amount_obj (i, &tps->amounts_obj[i]); } traits[NUM_TRAITS - 2] = TALER_TESTING_make_trait_url - (0, tps->exchange_url); + (0, tps->exchange_url); traits[NUM_TRAITS - 1] = TALER_TESTING_trait_end (); return TALER_TESTING_get_trait (traits, @@ -1099,11 +1100,11 @@ tip_pickup_traits (void *cls, struct TALER_TESTING_Command TALER_TESTING_cmd_tip_pickup_with_ec (const char *label, - const char *merchant_url, - unsigned int http_status, - const char *authorize_reference, - const char **amounts, - enum TALER_ErrorCode ec) + const char *merchant_url, + unsigned int http_status, + const char *authorize_reference, + const char **amounts, + enum TALER_ErrorCode ec) { struct TipPickupState *tps; @@ -1140,10 +1141,10 @@ TALER_TESTING_cmd_tip_pickup_with_ec struct TALER_TESTING_Command TALER_TESTING_cmd_tip_pickup (const char *label, - const char *merchant_url, - unsigned int http_status, - const char *authorize_reference, - const char **amounts) + const char *merchant_url, + unsigned int http_status, + const char *authorize_reference, + const char **amounts) { struct TipPickupState *tps; diff --git a/src/lib/testing_api_cmd_track.c b/src/lib/testing_api_cmd_track.c index 1f1596a4..8d5f7e76 100644 --- a/src/lib/testing_api_cmd_track.c +++ b/src/lib/testing_api_cmd_track.c @@ -162,14 +162,14 @@ track_transaction_cb (void *cls, json_t *exchange_url; if (NULL == (wtid_str = json_object_get - (json_array_get (json, 0), "wtid"))) + (json_array_get (json, 0), "wtid"))) { TALER_TESTING_interpreter_fail (tts->is); return; } if (NULL == (exchange_url = json_object_get - (json_array_get (json, 0), "exchange"))) + (json_array_get (json, 0), "exchange"))) { TALER_TESTING_interpreter_fail (tts->is); @@ -177,9 +177,9 @@ track_transaction_cb (void *cls, } tts->exchange_url = GNUNET_strdup - (json_string_value (exchange_url)); + (json_string_value (exchange_url)); tts->wtid_str = GNUNET_strdup - (json_string_value (wtid_str)); + (json_string_value (wtid_str)); } TALER_TESTING_interpreter_next (tts->is); } @@ -206,14 +206,14 @@ track_transaction_cb (void *cls, static void track_transfer_cb (void *cls, - unsigned int http_status, - enum TALER_ErrorCode ec, - const struct TALER_ExchangePublicKeyP *sign_key, - const json_t *json, - const struct GNUNET_HashCode *h_wire, - const struct TALER_Amount *total_amount, - unsigned int details_length, - const struct TALER_MERCHANT_TrackTransferDetails *details) + unsigned int http_status, + enum TALER_ErrorCode ec, + const struct TALER_ExchangePublicKeyP *sign_key, + const json_t *json, + const struct GNUNET_HashCode *h_wire, + const struct TALER_Amount *total_amount, + unsigned int details_length, + const struct TALER_MERCHANT_TrackTransferDetails *details) { /* FIXME, deeper checks should be implemented here. */ struct TrackTransferState *tts = cls; @@ -232,10 +232,10 @@ track_transfer_cb } switch (http_status) { - /** - * Check that all the deposits sum up to the total - * transferred amount. */ - case MHD_HTTP_OK: + /** + * Check that all the deposits sum up to the total + * transferred amount. */ + case MHD_HTTP_OK: { json_t *deposits; const char *amount_str; @@ -248,8 +248,8 @@ track_transfer_cb json_t *value; amount_str = json_string_value - (json_object_get (json, - "total")); + (json_object_get (json, + "total")); if (GNUNET_OK != TALER_string_to_amount (amount_str, &total)) @@ -261,8 +261,8 @@ track_transfer_cb return; } amount_str = json_string_value - (json_object_get (json, - "wire_fee")); + (json_object_get (json, + "wire_fee")); if (GNUNET_OK != TALER_string_to_amount (amount_str, &wire_fee)) @@ -281,8 +281,8 @@ track_transfer_cb json_array_foreach (deposits, index, value) { amount_str = json_string_value - (json_object_get (value, - "deposit_value")); + (json_object_get (value, + "deposit_value")); if (GNUNET_OK != TALER_string_to_amount (amount_str, &amount_iter)) @@ -294,8 +294,8 @@ track_transfer_cb return; } amount_str = json_string_value - (json_object_get (value, - "deposit_fee")); + (json_object_get (value, + "deposit_fee")); if (GNUNET_OK != TALER_string_to_amount (amount_str, &deposit_fee_iter)) @@ -326,16 +326,16 @@ track_transfer_cb GNUNET_break (0); TALER_LOG_ERROR ("Inconsistent amount transferred." - " Sum: %s, claimed: %s\n", - TALER_amount_to_string (&sum), - TALER_amount_to_string (&total)); + " Sum: %s, claimed: %s\n", + TALER_amount_to_string (&sum), + TALER_amount_to_string (&total)); TALER_TESTING_interpreter_fail (tts->is); } } break; - default: - GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - "Unhandled HTTP status.\n"); + default: + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, + "Unhandled HTTP status.\n"); } TALER_TESTING_interpreter_next (tts->is); } @@ -362,14 +362,14 @@ track_transfer_run (void *cls, tts->is = is; check_bank_cmd = TALER_TESTING_interpreter_lookup_command - (is, tts->check_bank_reference); + (is, tts->check_bank_reference); if (NULL == check_bank_cmd) TALER_TESTING_FAIL (is); if (GNUNET_OK != TALER_TESTING_get_trait_wtid - (check_bank_cmd, 0, &wtid)) + (check_bank_cmd, 0, &wtid)) TALER_TESTING_FAIL (is); if (GNUNET_OK != TALER_TESTING_get_trait_url - (check_bank_cmd, 0, &exchange_url)) + (check_bank_cmd, 0, &exchange_url)) TALER_TESTING_FAIL (is); tts->tth = TALER_MERCHANT_track_transfer (is->ctx, tts->merchant_url, @@ -400,20 +400,20 @@ track_transaction_run (void *cls, tts->is = is; if ( NULL == - ( pay_cmd = TALER_TESTING_interpreter_lookup_command - (is, tts->pay_reference))) + (pay_cmd = TALER_TESTING_interpreter_lookup_command + (is, tts->pay_reference))) TALER_TESTING_FAIL (is); if (GNUNET_OK != TALER_TESTING_get_trait_order_id - (pay_cmd, 0, &order_id)) + (pay_cmd, 0, &order_id)) TALER_TESTING_FAIL (is); tts->tth = TALER_MERCHANT_track_transaction - (is->ctx, - tts->merchant_url, - order_id, - &track_transaction_cb, - tts); + (is->ctx, + tts->merchant_url, + order_id, + &track_transaction_cb, + tts); GNUNET_assert (NULL != tts->tth); } @@ -492,10 +492,10 @@ track_transaction_traits (void *cls, struct TALER_WireTransferIdentifierRawP *wtid_ptr; if (GNUNET_OK != GNUNET_STRINGS_string_to_data - (tts->wtid_str, - strlen (tts->wtid_str), - &tts->wtid, - sizeof (struct TALER_WireTransferIdentifierRawP))) + (tts->wtid_str, + strlen (tts->wtid_str), + &tts->wtid, + sizeof (struct TALER_WireTransferIdentifierRawP))) wtid_ptr = NULL; else wtid_ptr = &tts->wtid; @@ -526,9 +526,9 @@ track_transaction_traits (void *cls, struct TALER_TESTING_Command TALER_TESTING_cmd_merchant_track_transaction (const char *label, - const char *merchant_url, - unsigned int http_status, - const char *pay_reference) + const char *merchant_url, + unsigned int http_status, + const char *pay_reference) { struct TrackTransactionState *tts; @@ -564,9 +564,9 @@ TALER_TESTING_cmd_merchant_track_transaction struct TALER_TESTING_Command TALER_TESTING_cmd_merchant_track_transfer (const char *label, - const char *merchant_url, - unsigned int http_status, - const char *check_bank_reference) + const char *merchant_url, + unsigned int http_status, + const char *check_bank_reference) { struct TrackTransferState *tts; diff --git a/src/lib/testing_api_helpers.c b/src/lib/testing_api_helpers.c index 2d1a9317..520600fb 100644 --- a/src/lib/testing_api_helpers.c +++ b/src/lib/testing_api_helpers.c @@ -72,22 +72,22 @@ TALER_TESTING_run_merchant (const char *config_filename, "Waiting for `taler-merchant-httpd' to be ready\n"); iter = 0; do + { + if (10 == iter) { - if (10 == iter) - { - fprintf (stderr, - "Failed to launch" - " `taler-merchant-httpd' (or `wget')\n"); - GNUNET_OS_process_kill (merchant_proc, - SIGTERM); - GNUNET_OS_process_wait (merchant_proc); - GNUNET_OS_process_destroy (merchant_proc); - MERCHANT_FAIL (); - } - fprintf (stderr, ".\n"); - sleep (1); - iter++; + fprintf (stderr, + "Failed to launch" + " `taler-merchant-httpd' (or `wget')\n"); + GNUNET_OS_process_kill (merchant_proc, + SIGTERM); + GNUNET_OS_process_wait (merchant_proc); + GNUNET_OS_process_destroy (merchant_proc); + MERCHANT_FAIL (); } + fprintf (stderr, ".\n"); + sleep (1); + iter++; + } while (0 != system (wget_cmd)); GNUNET_free (wget_cmd); fprintf (stderr, "\n"); @@ -141,20 +141,20 @@ TALER_TESTING_prepare_merchant (const char *config_filename) { fprintf (stderr, "Required port %llu not available, skipping.\n", - port); + port); MERCHANT_FAIL (); } /* DB preparation */ if (NULL == (dbinit_proc = GNUNET_OS_start_process - (GNUNET_NO, - GNUNET_OS_INHERIT_STD_ALL, - NULL, NULL, NULL, - "taler-merchant-dbinit", - "taler-merchant-dbinit", - "-c", config_filename, - "-r", - NULL))) + (GNUNET_NO, + GNUNET_OS_INHERIT_STD_ALL, + NULL, NULL, NULL, + "taler-merchant-dbinit", + "taler-merchant-dbinit", + "-c", config_filename, + "-r", + NULL))) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to run taler-merchant-dbinit." diff --git a/src/lib/testing_api_trait_hash.c b/src/lib/testing_api_trait_hash.c index 79cd38e3..08e50274 100644 --- a/src/lib/testing_api_trait_hash.c +++ b/src/lib/testing_api_trait_hash.c @@ -48,8 +48,8 @@ int TALER_TESTING_get_trait_tip_id (const struct TALER_TESTING_Command *cmd, - unsigned int index, - struct GNUNET_HashCode **tip_id) + unsigned int index, + struct GNUNET_HashCode **tip_id) { return cmd->traits (cmd->cls, (const void **) tip_id, @@ -69,7 +69,7 @@ TALER_TESTING_get_trait_tip_id struct TALER_TESTING_Trait TALER_TESTING_make_trait_tip_id (unsigned int index, - const struct GNUNET_HashCode *tip_id) + const struct GNUNET_HashCode *tip_id) { struct TALER_TESTING_Trait ret = { .index = index, @@ -92,8 +92,8 @@ TALER_TESTING_make_trait_tip_id int TALER_TESTING_get_trait_h_contract_terms (const struct TALER_TESTING_Command *cmd, - unsigned int index, - const struct GNUNET_HashCode **h_contract_terms) + unsigned int index, + const struct GNUNET_HashCode **h_contract_terms) { return cmd->traits (cmd->cls, (const void **) h_contract_terms, @@ -115,7 +115,7 @@ TALER_TESTING_get_trait_h_contract_terms struct TALER_TESTING_Trait TALER_TESTING_make_trait_h_contract_terms (unsigned int index, - const struct GNUNET_HashCode *h_contract_terms) + const struct GNUNET_HashCode *h_contract_terms) { struct TALER_TESTING_Trait ret = { .index = index, diff --git a/src/lib/testing_api_trait_merchant_sig.c b/src/lib/testing_api_trait_merchant_sig.c index 2f39f531..4b4e0710 100644 --- a/src/lib/testing_api_trait_merchant_sig.c +++ b/src/lib/testing_api_trait_merchant_sig.c @@ -41,8 +41,8 @@ int TALER_TESTING_get_trait_merchant_sig (const struct TALER_TESTING_Command *cmd, - unsigned int index, - struct TALER_MerchantSignatureP **merchant_sig) + unsigned int index, + struct TALER_MerchantSignatureP **merchant_sig) { return cmd->traits (cmd->cls, (const void **) merchant_sig, @@ -62,7 +62,7 @@ TALER_TESTING_get_trait_merchant_sig struct TALER_TESTING_Trait TALER_TESTING_make_trait_merchant_sig (unsigned int index, - const struct TALER_MerchantSignatureP *merchant_sig) + const struct TALER_MerchantSignatureP *merchant_sig) { struct TALER_TESTING_Trait ret = { .index = index, diff --git a/src/lib/testing_api_trait_planchet.c b/src/lib/testing_api_trait_planchet.c index 3c8a6dca..d290e8ea 100644 --- a/src/lib/testing_api_trait_planchet.c +++ b/src/lib/testing_api_trait_planchet.c @@ -40,8 +40,8 @@ int TALER_TESTING_get_trait_planchet_secrets (const struct TALER_TESTING_Command *cmd, - unsigned int index, - struct TALER_PlanchetSecretsP **planchet_secrets) + unsigned int index, + struct TALER_PlanchetSecretsP **planchet_secrets) { return cmd->traits (cmd->cls, (const void **) planchet_secrets, @@ -60,7 +60,7 @@ TALER_TESTING_get_trait_planchet_secrets struct TALER_TESTING_Trait TALER_TESTING_make_trait_planchet_secrets (unsigned int index, - const struct TALER_PlanchetSecretsP *planchet_secrets) + const struct TALER_PlanchetSecretsP *planchet_secrets) { struct TALER_TESTING_Trait ret = { .index = index, diff --git a/src/lib/testing_api_trait_refund_entry.c b/src/lib/testing_api_trait_refund_entry.c index 502c0875..bc947e2b 100644 --- a/src/lib/testing_api_trait_refund_entry.c +++ b/src/lib/testing_api_trait_refund_entry.c @@ -43,8 +43,8 @@ int TALER_TESTING_get_trait_refund_entry (const struct TALER_TESTING_Command *cmd, - unsigned int index, - const struct TALER_MERCHANT_RefundEntry **refund_entry) + unsigned int index, + const struct TALER_MERCHANT_RefundEntry **refund_entry) { return cmd->traits (cmd->cls, (const void **) refund_entry, @@ -63,7 +63,7 @@ TALER_TESTING_get_trait_refund_entry struct TALER_TESTING_Trait TALER_TESTING_make_trait_refund_entry (unsigned int index, - const struct TALER_MERCHANT_RefundEntry *refund_entry) + const struct TALER_MERCHANT_RefundEntry *refund_entry) { 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 226428e7..30db2f6a 100644 --- a/src/lib/testing_api_trait_string.c +++ b/src/lib/testing_api_trait_string.c @@ -47,8 +47,8 @@ int TALER_TESTING_get_trait_proposal_reference (const struct TALER_TESTING_Command *cmd, - unsigned int index, - const char **proposal_reference) + unsigned int index, + const char **proposal_reference) { return cmd->traits (cmd->cls, (const void **) proposal_reference, @@ -69,7 +69,7 @@ TALER_TESTING_get_trait_proposal_reference struct TALER_TESTING_Trait TALER_TESTING_make_trait_proposal_reference (unsigned int index, - const char *proposal_reference) + const char *proposal_reference) { struct TALER_TESTING_Trait ret = { .index = index, @@ -100,8 +100,8 @@ TALER_TESTING_make_trait_proposal_reference int TALER_TESTING_get_trait_coin_reference (const struct TALER_TESTING_Command *cmd, - unsigned int index, - const char **coin_reference) + unsigned int index, + const char **coin_reference) { return cmd->traits (cmd->cls, (const void **) coin_reference, @@ -122,7 +122,7 @@ TALER_TESTING_get_trait_coin_reference struct TALER_TESTING_Trait TALER_TESTING_make_trait_coin_reference (unsigned int index, - const char *coin_reference) + const char *coin_reference) { struct TALER_TESTING_Trait ret = { .index = index, diff --git a/src/merchant-tools/taler-merchant-benchmark.c b/src/merchant-tools/taler-merchant-benchmark.c index 9bd80ff8..58d4ac8a 100644 --- a/src/merchant-tools/taler-merchant-benchmark.c +++ b/src/merchant-tools/taler-merchant-benchmark.c @@ -39,7 +39,8 @@ #include "taler_merchant_testing_lib.h" /* Error codes. */ -enum PaymentGeneratorError { +enum PaymentGeneratorError +{ MISSING_MERCHANT_URL = 2, FAILED_TO_LAUNCH_MERCHANT, @@ -65,9 +66,11 @@ enum PaymentGeneratorError { #define TWOCOINS_INSTRUCTION 5 #define CMD_TRANSFER_TO_EXCHANGE(label,amount) \ - TALER_TESTING_cmd_fakebank_transfer (label, amount, \ - bank_url, USER_ACCOUNT_NO, EXCHANGE_ACCOUNT_NO, \ - USER_LOGIN_NAME, USER_LOGIN_PASS, EXCHANGE_URL) + TALER_TESTING_cmd_fakebank_transfer (label, amount, \ + bank_url, USER_ACCOUNT_NO, \ + EXCHANGE_ACCOUNT_NO, \ + USER_LOGIN_NAME, USER_LOGIN_PASS, \ + EXCHANGE_URL) /** * Help string shown if NO subcommand is given on command line. @@ -223,7 +226,7 @@ static char *currency; \ GNUNET_asprintf \ (&order_worth_5, \ - "{\"max_fee\":\ + "{\"max_fee\":\ {\"currency\":\"%s\",\ \"value\":0,\ \"fraction\":50000000},\ @@ -237,12 +240,12 @@ static char *currency; \"fulfillment_url\": \"https://example.com/\",\ \"products\": [ {\"description\":\"ice cream\",\ \"value\":\"{%s:5}\"} ] }", \ - currency, \ - currency, \ - currency); \ + currency, \ + currency, \ + currency); \ GNUNET_asprintf \ (&order_worth_5_track, \ - "{\"max_fee\":\ + "{\"max_fee\":\ {\"currency\":\"%s\",\ \"value\":0,\ \"fraction\":50000000},\ @@ -256,12 +259,12 @@ static char *currency; \"fulfillment_url\": \"https://example.com/\",\ \"products\": [ {\"description\":\"ice track cream\",\ \"value\":\"{%s:5}\"} ] }", \ - currency, \ - currency, \ - currency); \ + currency, \ + currency, \ + currency); \ GNUNET_asprintf \ (&order_worth_5_unaggregated, \ - "{\"max_fee\":\ + "{\"max_fee\":\ {\"currency\":\"%s\",\ \"value\":0,\ \"fraction\":50000000},\ @@ -276,12 +279,12 @@ static char *currency; \"fulfillment_url\": \"https://example.com/\",\ \"products\": [ {\"description\":\"unaggregated cream\",\ \"value\":\"{%s:5}\"} ] }", \ - currency, \ - currency, \ - currency); \ + currency, \ + currency, \ + currency); \ GNUNET_asprintf \ (&order_worth_10_2coins, \ - "{\"max_fee\":\ + "{\"max_fee\":\ {\"currency\":\"%s\",\ \"value\":0,\ \"fraction\":50000000},\ @@ -295,9 +298,9 @@ static char *currency; \"fulfillment_url\": \"https://example.com/\",\ \"products\": [ {\"description\":\"2-coins payment\",\ \"value\":\"{%s:10}\"} ] }", \ - currency, \ - currency, \ - currency); + currency, \ + currency, \ + currency); /** @@ -314,62 +317,62 @@ run (void *cls, (is->ctx, APIKEY_SANDBOX)); ALLOCATE_AMOUNTS - (CURRENCY_10_02, - CURRENCY_9_98, - CURRENCY_5_01, - CURRENCY_5, - CURRENCY_4_99, - CURRENCY_0_02, - CURRENCY_0_01); + (CURRENCY_10_02, + CURRENCY_9_98, + CURRENCY_5_01, + CURRENCY_5, + CURRENCY_4_99, + CURRENCY_0_02, + CURRENCY_0_01); ALLOCATE_ORDERS (order_worth_5, - order_worth_5_track, - order_worth_5_unaggregated, - order_worth_10_2coins); + order_worth_5_track, + order_worth_5_unaggregated, + order_worth_10_2coins); struct TALER_TESTING_Command ordinary_commands[] = { CMD_TRANSFER_TO_EXCHANGE ("create-reserve-1", - CURRENCY_10_02), + CURRENCY_10_02), TALER_TESTING_cmd_exec_wirewatch ("wirewatch-1", - cfg_filename), + cfg_filename), TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-1", - "create-reserve-1", - CURRENCY_5, - MHD_HTTP_OK), + "create-reserve-1", + CURRENCY_5, + MHD_HTTP_OK), TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-2", - "create-reserve-1", - CURRENCY_5, - MHD_HTTP_OK), + "create-reserve-1", + CURRENCY_5, + MHD_HTTP_OK), TALER_TESTING_cmd_proposal ("create-proposal-1", - merchant_url, - MHD_HTTP_OK, - order_worth_5), + merchant_url, + MHD_HTTP_OK, + order_worth_5), TALER_TESTING_cmd_pay ("deposit-simple", - merchant_url, - MHD_HTTP_OK, - "create-proposal-1", - "withdraw-coin-1", - CURRENCY_5, - CURRENCY_4_99, - CURRENCY_0_01), + merchant_url, + MHD_HTTP_OK, + "create-proposal-1", + "withdraw-coin-1", + CURRENCY_5, + CURRENCY_4_99, + CURRENCY_0_01), TALER_TESTING_cmd_rewind_ip ("rewind-payments", - FIRST_INSTRUCTION, - &payments_number), + FIRST_INSTRUCTION, + &payments_number), /* Next proposal-pay cycle will be used by /track CMDs * and so it will not have to be looped over, only /track @@ -377,42 +380,42 @@ run (void *cls, TALER_TESTING_cmd_proposal ("create-proposal-2", - merchant_url, - MHD_HTTP_OK, - order_worth_5_track), + merchant_url, + MHD_HTTP_OK, + order_worth_5_track), TALER_TESTING_cmd_pay ("deposit-simple-2", - merchant_url, - MHD_HTTP_OK, - "create-proposal-2", - "withdraw-coin-2", - CURRENCY_5, - CURRENCY_4_99, - CURRENCY_0_01), + merchant_url, + MHD_HTTP_OK, + "create-proposal-2", + "withdraw-coin-2", + CURRENCY_5, + CURRENCY_4_99, + CURRENCY_0_01), /* /track/transaction over deposit-simple-2 */ TALER_TESTING_cmd_exec_aggregator ("aggregate-1", - cfg_filename), + cfg_filename), TALER_TESTING_cmd_merchant_track_transaction ("track-transaction-1", - merchant_url, - MHD_HTTP_OK, - "deposit-simple-2"), + merchant_url, + MHD_HTTP_OK, + "deposit-simple-2"), TALER_TESTING_cmd_merchant_track_transfer ("track-transfer-1", - merchant_url, - MHD_HTTP_OK, - "track-transaction-1"), + merchant_url, + MHD_HTTP_OK, + "track-transaction-1"), TALER_TESTING_cmd_rewind_ip ("rewind-tracks", - TRACKS_INSTRUCTION, - &tracks_number), + TRACKS_INSTRUCTION, + &tracks_number), TALER_TESTING_cmd_end () }; @@ -421,83 +424,83 @@ run (void *cls, CMD_TRANSFER_TO_EXCHANGE ("create-reserve-1", - CURRENCY_5_01), + CURRENCY_5_01), TALER_TESTING_cmd_exec_wirewatch ("wirewatch-1", - cfg_filename), + cfg_filename), TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-1", - "create-reserve-1", - CURRENCY_5, - MHD_HTTP_OK), + "create-reserve-1", + CURRENCY_5, + MHD_HTTP_OK), TALER_TESTING_cmd_proposal ("create-unaggregated-proposal", - alt_instance_url, - MHD_HTTP_OK, - order_worth_5_unaggregated), + alt_instance_url, + MHD_HTTP_OK, + order_worth_5_unaggregated), TALER_TESTING_cmd_pay ("deposit-unaggregated", - merchant_url, - MHD_HTTP_OK, - "create-unaggregated-proposal", - "withdraw-coin-1", - CURRENCY_5, - CURRENCY_4_99, - CURRENCY_0_01), + merchant_url, + MHD_HTTP_OK, + "create-unaggregated-proposal", + "withdraw-coin-1", + CURRENCY_5, + CURRENCY_4_99, + CURRENCY_0_01), TALER_TESTING_cmd_rewind_ip ("rewind-unaggregated", - FIRST_INSTRUCTION, - &unaggregated_number), + FIRST_INSTRUCTION, + &unaggregated_number), CMD_TRANSFER_TO_EXCHANGE ("create-reserve-2", - CURRENCY_10_02), + CURRENCY_10_02), TALER_TESTING_cmd_exec_wirewatch ("wirewatch-2", - cfg_filename), + cfg_filename), TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-2", - "create-reserve-2", - CURRENCY_5, - MHD_HTTP_OK), + "create-reserve-2", + CURRENCY_5, + MHD_HTTP_OK), TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-3", - "create-reserve-2", - CURRENCY_5, - MHD_HTTP_OK), + "create-reserve-2", + CURRENCY_5, + MHD_HTTP_OK), TALER_TESTING_cmd_proposal ("create-twocoins-proposal", - merchant_url, - MHD_HTTP_OK, - order_worth_10_2coins), + merchant_url, + MHD_HTTP_OK, + order_worth_10_2coins), TALER_TESTING_cmd_pay ("deposit-twocoins", - merchant_url, - MHD_HTTP_OK, - "create-twocoins-proposal", - "withdraw-coin-2;withdraw-coin-3", - CURRENCY_10, - CURRENCY_9_98, - CURRENCY_0_02), + merchant_url, + MHD_HTTP_OK, + "create-twocoins-proposal", + "withdraw-coin-2;withdraw-coin-3", + CURRENCY_10, + CURRENCY_9_98, + CURRENCY_0_02), TALER_TESTING_cmd_exec_aggregator ("aggregate-twocoins", - cfg_filename), + cfg_filename), TALER_TESTING_cmd_rewind_ip ("rewind-twocoins", - TWOCOINS_INSTRUCTION, - &twocoins_number), + TWOCOINS_INSTRUCTION, + &twocoins_number), TALER_TESTING_cmd_end () }; @@ -515,7 +518,7 @@ run (void *cls, corner_commands); return; } - + /* Should never get here, as the control on subcommands * happens earlier at launch time. */ fprintf (stderr, @@ -549,7 +552,7 @@ main (int argc, char *const *argv) { default_config_file = GNUNET_OS_project_data_get - ()->user_config_file; + ()->user_config_file; loglev = NULL; GNUNET_log_setup ("taler-merchant-benchmark", @@ -568,9 +571,9 @@ main (int argc, GNUNET_GETOPT_option_flag ('h', - "help", - NULL, - &root_help), + "help", + NULL, + &root_help), GNUNET_GETOPT_OPTION_END }; @@ -585,17 +588,17 @@ main (int argc, GNUNET_GETOPT_option_uint ('u', - "unaggregated-number", - "UN", - "will generate UN unaggregated payments, defaults to 1", - &unaggregated_number), + "unaggregated-number", + "UN", + "will generate UN unaggregated payments, defaults to 1", + &unaggregated_number), GNUNET_GETOPT_option_uint ('t', - "two-coins", - "TC", - "will perform TC 2-coins payments, defaults to 1", - &twocoins_number), + "two-coins", + "TC", + "will perform TC 2-coins payments, defaults to 1", + &twocoins_number), /** * NOTE: useful when the setup serves merchant @@ -606,45 +609,45 @@ main (int argc, */ GNUNET_GETOPT_option_string ('m', - "merchant-url", - "MU", - "merchant base url, mandatory", - &merchant_url), + "merchant-url", + "MU", + "merchant base url, mandatory", + &merchant_url), GNUNET_GETOPT_option_string ('k', - "currency", - "K", - "Used currency, mandatory", - ¤cy), + "currency", + "K", + "Used currency, mandatory", + ¤cy), GNUNET_GETOPT_option_string ('i', - "alt-instance", - "AI", - "alternative (non default) instance," - " used to provide fresh wire details to" - " make unaggregated transactions stay so." - " Note, this instance will be given far" - " future wire deadline, and so it should" - " never author now-deadlined transactions," - " as they would get those far future ones" - " aggregated too.", - &alt_instance_id), + "alt-instance", + "AI", + "alternative (non default) instance," + " used to provide fresh wire details to" + " make unaggregated transactions stay so." + " Note, this instance will be given far" + " future wire deadline, and so it should" + " never author now-deadlined transactions," + " as they would get those far future ones" + " aggregated too.", + &alt_instance_id), GNUNET_GETOPT_option_string ('b', - "bank-url", - "BU", - "bank base url, mandatory", - &bank_url), + "bank-url", + "BU", + "bank base url, mandatory", + &bank_url), GNUNET_GETOPT_option_string ('l', - "logfile", - "LF", - "will log to file LF", - &logfile), + "logfile", + "LF", + "will log to file LF", + &logfile), GNUNET_GETOPT_OPTION_END }; @@ -659,24 +662,24 @@ main (int argc, GNUNET_GETOPT_option_help ("Generate Taler ordinary payments" - " to populate the databases"), + " to populate the databases"), GNUNET_GETOPT_option_loglevel (&loglev), GNUNET_GETOPT_option_uint ('p', - "payments-number", - "PN", - "will generate PN payments, defaults to 1", - &payments_number), + "payments-number", + "PN", + "will generate PN payments, defaults to 1", + &payments_number), GNUNET_GETOPT_option_uint ('t', - "tracks-number", - "TN", - "will perform TN /track operations, defaults to 1", - &tracks_number), + "tracks-number", + "TN", + "will perform TN /track operations, defaults to 1", + &tracks_number), /** * NOTE: useful when the setup serves merchant @@ -687,28 +690,28 @@ main (int argc, */ GNUNET_GETOPT_option_string ('m', - "merchant-url", - "MU", - "merchant base url, mandatory", - &merchant_url), + "merchant-url", + "MU", + "merchant base url, mandatory", + &merchant_url), GNUNET_GETOPT_option_string ('b', - "bank-url", - "BU", - "bank base url, mandatory", - &bank_url), + "bank-url", + "BU", + "bank base url, mandatory", + &bank_url), GNUNET_GETOPT_option_string ('l', - "logfile", - "LF", - "will log to file LF", - &logfile), + "logfile", + "LF", + "will log to file LF", + &logfile), GNUNET_GETOPT_OPTION_END }; - + options = root_options; if (NULL != argv[1]) @@ -726,10 +729,10 @@ main (int argc, } if (GNUNET_SYSERR != (result = GNUNET_GETOPT_run - ("taler-merchant-benchmark", - options, - argc, - argv))) + ("taler-merchant-benchmark", + options, + argc, + argv))) { if (GNUNET_YES == root_help) @@ -740,7 +743,7 @@ main (int argc, } /* --help was given. */ - if (0 == result) + if (0 == result) return 0; } @@ -752,14 +755,14 @@ main (int argc, if ((GNUNET_YES != ordinary) && (GNUNET_YES != corner)) { fprintf (stderr, - "Please use 'ordinary' or 'corner' subcommands.\n"); + "Please use 'ordinary' or 'corner' subcommands.\n"); return 1; } if ((GNUNET_YES == corner) && (NULL == alt_instance_id)) { fprintf (stderr, "option '-i' is mandatory" - " with sub-command 'corner'!\n"); + " with sub-command 'corner'!\n"); return 1; } @@ -787,7 +790,7 @@ main (int argc, } if (NULL == (merchantd = TALER_TESTING_run_merchant - (cfg_filename, merchant_url))) + (cfg_filename, merchant_url))) { TALER_LOG_ERROR ("Failed to launch the merchant\n"); return FAILED_TO_LAUNCH_MERCHANT; @@ -801,8 +804,8 @@ main (int argc, } if ( NULL == (bankd = TALER_TESTING_run_bank - (cfg_filename, - bank_url))) + (cfg_filename, + bank_url))) { TALER_LOG_ERROR ("Failed to run the bank\n"); terminate_process (merchantd); @@ -810,9 +813,9 @@ main (int argc, } result = TALER_TESTING_setup_with_exchange - (run, - NULL, - cfg_filename); + (run, + NULL, + cfg_filename); terminate_process (merchantd); terminate_process (bankd); diff --git a/src/merchant-tools/taler-merchant-dbinit.c b/src/merchant-tools/taler-merchant-dbinit.c index e846100c..2da6cd50 100644 --- a/src/merchant-tools/taler-merchant-dbinit.c +++ b/src/merchant-tools/taler-merchant-dbinit.c @@ -90,9 +90,9 @@ main (int argc, 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_END }; @@ -108,9 +108,9 @@ main (int argc, if (GNUNET_OK != GNUNET_PROGRAM_run (argc, argv, "taler-merchant-dbinit", - "Initialize Taler merchant database", - options, - &run, NULL)) + "Initialize Taler merchant database", + options, + &run, NULL)) return 1; return global_ret; } |