diff options
author | Christian Grothoff <christian@grothoff.org> | 2024-08-27 00:50:54 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2024-08-27 00:50:54 +0200 |
commit | b7ff489a848d6992f4500fab470f0392ad8c8a1b (patch) | |
tree | aedbe9a6f3bdd1030eea9f5df83bd668a457559b | |
parent | 0891c96a527c827501169f842c02deb04515ddaa (diff) |
-misc code cleanups
-rw-r--r-- | src/backend/Makefile.am | 2 | ||||
-rw-r--r-- | src/backend/taler-merchant-httpd_config.c | 3 | ||||
-rw-r--r-- | src/backend/taler-merchant-httpd_get-templates-ID.c | 2 | ||||
-rw-r--r-- | src/backend/taler-merchant-httpd_private-get-instances-ID-kyc.c | 5 | ||||
-rw-r--r-- | src/backend/taler-merchant-httpd_private-get-orders.c | 2 | ||||
-rw-r--r-- | src/backend/taler-merchant-httpd_private-patch-orders-ID-forget.c | 3 | ||||
-rw-r--r-- | src/backend/taler-merchant-httpd_spa.c | 1 | ||||
-rw-r--r-- | src/backenddb/pg_insert_deposit_confirmation.c | 2 | ||||
-rw-r--r-- | src/backenddb/pg_insert_spent_token.c | 20 | ||||
-rw-r--r-- | src/backenddb/pg_insert_spent_token.h | 13 | ||||
-rw-r--r-- | src/backenddb/pg_insert_token_family.c | 59 | ||||
-rw-r--r-- | src/backenddb/pg_insert_token_family_key.c | 37 | ||||
-rw-r--r-- | src/backenddb/pg_lookup_all_products.c | 2 | ||||
-rw-r--r-- | src/backenddb/pg_lookup_token_family.c | 9 | ||||
-rw-r--r-- | src/backenddb/pg_select_account.c | 2 |
15 files changed, 80 insertions, 82 deletions
diff --git a/src/backend/Makefile.am b/src/backend/Makefile.am index cce7faec..c9c408de 100644 --- a/src/backend/Makefile.am +++ b/src/backend/Makefile.am @@ -1,5 +1,5 @@ # This Makefile.am is in the public domain -AM_CPPFLAGS = -I$(top_srcdir)/src/include -I$(top_srcdir)/src/backend-lib/ +AM_CPPFLAGS = -I$(top_srcdir)/src/include if USE_COVERAGE AM_CFLAGS = --coverage -O0 diff --git a/src/backend/taler-merchant-httpd_config.c b/src/backend/taler-merchant-httpd_config.c index 10f0cd39..96394198 100644 --- a/src/backend/taler-merchant-httpd_config.c +++ b/src/backend/taler-merchant-httpd_config.c @@ -23,6 +23,7 @@ #include <taler/taler_util.h> #include <taler/taler_json_lib.h> #include "taler-merchant-httpd.h" +#include "taler-merchant-httpd_config.h" #include "taler-merchant-httpd_mhd.h" #include "taler-merchant-httpd_exchanges.h" @@ -77,7 +78,7 @@ add_exchange (void *cls, MHD_RESULT -MH_handler_config (struct TMH_RequestHandler *rh, +MH_handler_config (const struct TMH_RequestHandler *rh, struct MHD_Connection *connection, struct TMH_HandlerContext *hc) { diff --git a/src/backend/taler-merchant-httpd_get-templates-ID.c b/src/backend/taler-merchant-httpd_get-templates-ID.c index a2ad9bff..6b39496c 100644 --- a/src/backend/taler-merchant-httpd_get-templates-ID.c +++ b/src/backend/taler-merchant-httpd_get-templates-ID.c @@ -19,7 +19,7 @@ * @author Priscilla HUANG */ #include "platform.h" -#include "taler-merchant-httpd_private-get-templates-ID.h" +#include "taler-merchant-httpd_get-templates-ID.h" #include <taler/taler_json_lib.h> diff --git a/src/backend/taler-merchant-httpd_private-get-instances-ID-kyc.c b/src/backend/taler-merchant-httpd_private-get-instances-ID-kyc.c index 9af2c8f8..69a9d2b6 100644 --- a/src/backend/taler-merchant-httpd_private-get-instances-ID-kyc.c +++ b/src/backend/taler-merchant-httpd_private-get-instances-ID-kyc.c @@ -455,9 +455,8 @@ ekr_finished (struct ExchangeKycRequest *ekr) after we asked at the exchanges => 204 */ struct MHD_Response *response; - response = MHD_create_response_from_buffer (0, - "", - MHD_RESPMEM_PERSISTENT); + response = MHD_create_response_from_buffer_static (0, + ""); resume_kyc_with_response (kc, MHD_HTTP_NO_CONTENT, response); diff --git a/src/backend/taler-merchant-httpd_private-get-orders.c b/src/backend/taler-merchant-httpd_private-get-orders.c index 3e60c153..13afee0a 100644 --- a/src/backend/taler-merchant-httpd_private-get-orders.c +++ b/src/backend/taler-merchant-httpd_private-get-orders.c @@ -503,7 +503,7 @@ resume_by_event (void *cls, GNUNET_break (0); return; } - osf = (enum TMH_OrderStateFlags) ntohl (oce->order_state); + osf = (enum TMH_OrderStateFlags) (int) ntohl (oce->order_state); order_serial_id = GNUNET_ntohll (oce->order_serial_id); date = GNUNET_TIME_timestamp_ntoh (oce->execution_date); GNUNET_log (GNUNET_ERROR_TYPE_INFO, diff --git a/src/backend/taler-merchant-httpd_private-patch-orders-ID-forget.c b/src/backend/taler-merchant-httpd_private-patch-orders-ID-forget.c index cb64d607..46afefad 100644 --- a/src/backend/taler-merchant-httpd_private-patch-orders-ID-forget.c +++ b/src/backend/taler-merchant-httpd_private-patch-orders-ID-forget.c @@ -16,14 +16,13 @@ License along with TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> */ - /** * @file taler-merchant-httpd_private-patch-orders-ID-forget.c * @brief implementing PATCH /orders/$ORDER_ID/forget request handling * @author Jonathan Buchanan */ #include "platform.h" -#include "taler-merchant-httpd_private-patch-instances-ID.h" +#include "taler-merchant-httpd_private-patch-orders-ID-forget.h" #include <taler/taler_json_lib.h> diff --git a/src/backend/taler-merchant-httpd_spa.c b/src/backend/taler-merchant-httpd_spa.c index b12200b8..4fc64042 100644 --- a/src/backend/taler-merchant-httpd_spa.c +++ b/src/backend/taler-merchant-httpd_spa.c @@ -23,6 +23,7 @@ #include <taler/taler_util.h> #include <taler/taler_mhd_lib.h> #include "taler-merchant-httpd_statics.h" +#include "taler-merchant-httpd_spa.h" #include <gnunet/gnunet_mhd_compat.h> diff --git a/src/backenddb/pg_insert_deposit_confirmation.c b/src/backenddb/pg_insert_deposit_confirmation.c index f23bf252..7e1d01d1 100644 --- a/src/backenddb/pg_insert_deposit_confirmation.c +++ b/src/backenddb/pg_insert_deposit_confirmation.c @@ -22,7 +22,7 @@ #include <taler/taler_error_codes.h> #include <taler/taler_dbevents.h> #include <taler/taler_pq_lib.h> -#include "pg_insert_deposit.h" +#include "pg_insert_deposit_confirmation.h" #include "pg_helper.h" diff --git a/src/backenddb/pg_insert_spent_token.c b/src/backenddb/pg_insert_spent_token.c index 1f11c5a3..bb3ffcdc 100644 --- a/src/backenddb/pg_insert_spent_token.c +++ b/src/backenddb/pg_insert_spent_token.c @@ -18,9 +18,6 @@ * @brief Implementation of the insert_spent_token function for Postgres * @author Christian Blättler */ -#ifndef PG_INSERT_SPENT_TOKEN_H -#define PG_INSERT_SPENT_TOKEN_H - #include "platform.h" #include <taler/taler_error_codes.h> #include <taler/taler_dbevents.h> @@ -28,16 +25,17 @@ #include "pg_insert_spent_token.h" #include "pg_helper.h" + enum GNUNET_DB_QueryStatus -TMH_PG_insert_spent_token (void *cls, - const struct TALER_PrivateContractHashP *h_contract_terms, - const struct TALER_TokenIssuePublicKeyHashP *h_issue_pub, - const struct TALER_TokenUsePublicKeyP *use_pub, - const struct TALER_TokenUseSignatureP *use_sig, - const struct TALER_TokenIssueSignatureP *issue_sig) +TMH_PG_insert_spent_token ( + void *cls, + const struct TALER_PrivateContractHashP *h_contract_terms, + const struct TALER_TokenIssuePublicKeyHashP *h_issue_pub, + const struct TALER_TokenUsePublicKeyP *use_pub, + const struct TALER_TokenUseSignatureP *use_sig, + const struct TALER_TokenIssueSignatureP *issue_sig) { struct PostgresClosure *pg = cls; - struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (h_issue_pub), GNUNET_PQ_query_param_auto_from_type (h_contract_terms), @@ -68,5 +66,3 @@ TMH_PG_insert_spent_token (void *cls, "spent_token_insert", params); } - -#endif
\ No newline at end of file diff --git a/src/backenddb/pg_insert_spent_token.h b/src/backenddb/pg_insert_spent_token.h index c2857c45..c618213f 100644 --- a/src/backenddb/pg_insert_spent_token.h +++ b/src/backenddb/pg_insert_spent_token.h @@ -36,11 +36,12 @@ * @return database result code */ enum GNUNET_DB_QueryStatus -TMH_PG_insert_spent_token (void *cls, - const struct TALER_PrivateContractHashP *h_contract_terms, - const struct TALER_TokenIssuePublicKeyHashP *h_issue_pub, - const struct TALER_TokenUsePublicKeyP *use_pub, - const struct TALER_TokenUseSignatureP *use_sig, - const struct TALER_TokenIssueSignatureP *issue_sig); +TMH_PG_insert_spent_token ( + void *cls, + const struct TALER_PrivateContractHashP *h_contract_terms, + const struct TALER_TokenIssuePublicKeyHashP *h_issue_pub, + const struct TALER_TokenUsePublicKeyP *use_pub, + const struct TALER_TokenUseSignatureP *use_sig, + const struct TALER_TokenIssueSignatureP *issue_sig); #endif diff --git a/src/backenddb/pg_insert_token_family.c b/src/backenddb/pg_insert_token_family.c index f533a2fb..81a1890b 100644 --- a/src/backenddb/pg_insert_token_family.c +++ b/src/backenddb/pg_insert_token_family.c @@ -29,38 +29,25 @@ enum GNUNET_DB_QueryStatus TMH_PG_insert_token_family (void *cls, const char *instance_id, const char *token_family_slug, - const struct TALER_MERCHANTDB_TokenFamilyDetails *details) + const struct TALER_MERCHANTDB_TokenFamilyDetails * + details) { struct PostgresClosure *pg = cls; - const char *kind; + switch (details->kind) { - case TALER_MERCHANTDB_TFK_Discount: - kind = "discount"; - break; - case TALER_MERCHANTDB_TFK_Subscription: - kind = "subscription"; - break; - default: - GNUNET_break (0); - return GNUNET_DB_STATUS_HARD_ERROR; + case TALER_MERCHANTDB_TFK_Discount: + kind = "discount"; + break; + case TALER_MERCHANTDB_TFK_Subscription: + kind = "subscription"; + break; + default: + GNUNET_break (0); + return GNUNET_DB_STATUS_HARD_ERROR; } - struct GNUNET_PQ_QueryParam params[] = { - GNUNET_PQ_query_param_string (instance_id), - GNUNET_PQ_query_param_string (token_family_slug), - GNUNET_PQ_query_param_string (details->name), - GNUNET_PQ_query_param_string (details->description), - TALER_PQ_query_param_json (details->description_i18n), - GNUNET_PQ_query_param_timestamp (&details->valid_after), - GNUNET_PQ_query_param_timestamp (&details->valid_before), - GNUNET_PQ_query_param_relative_time (&details->duration), - GNUNET_PQ_query_param_relative_time (&details->rounding), - GNUNET_PQ_query_param_string (kind), - GNUNET_PQ_query_param_end - }; - check_connection (pg); PREPARE (pg, "insert_token_family", @@ -78,7 +65,23 @@ TMH_PG_insert_token_family (void *cls, " SELECT merchant_serial, $2, $3, $4, $5, $6, $7, $8, $9, $10" " FROM merchant_instances" " WHERE merchant_id=$1"); - return GNUNET_PQ_eval_prepared_non_select (pg->conn, - "insert_token_family", - params); + { + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_string (instance_id), + GNUNET_PQ_query_param_string (token_family_slug), + GNUNET_PQ_query_param_string (details->name), + GNUNET_PQ_query_param_string (details->description), + TALER_PQ_query_param_json (details->description_i18n), + GNUNET_PQ_query_param_timestamp (&details->valid_after), + GNUNET_PQ_query_param_timestamp (&details->valid_before), + GNUNET_PQ_query_param_relative_time (&details->duration), + GNUNET_PQ_query_param_relative_time (&details->rounding), + GNUNET_PQ_query_param_string (kind), + GNUNET_PQ_query_param_end + }; + + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "insert_token_family", + params); + } } diff --git a/src/backenddb/pg_insert_token_family_key.c b/src/backenddb/pg_insert_token_family_key.c index b6602931..2fcbf026 100644 --- a/src/backenddb/pg_insert_token_family_key.c +++ b/src/backenddb/pg_insert_token_family_key.c @@ -55,20 +55,8 @@ TMH_PG_insert_token_family_key (void *cls, case GNUNET_CRYPTO_BSA_INVALID: return GNUNET_DB_STATUS_HARD_ERROR; } - - struct GNUNET_PQ_QueryParam params[] = { - GNUNET_PQ_query_param_string (token_family_slug), - GNUNET_PQ_query_param_blind_sign_pub (pub->public_key), - GNUNET_PQ_query_param_auto_from_type (&pub->public_key->pub_key_hash), - GNUNET_PQ_query_param_blind_sign_priv (priv->private_key), - GNUNET_PQ_query_param_timestamp (&valid_after), - GNUNET_PQ_query_param_timestamp (&valid_before), - GNUNET_PQ_query_param_string (cipher), - GNUNET_PQ_query_param_end - }; - - GNUNET_assert (pub->public_key->cipher == priv->private_key->cipher); - + GNUNET_assert (pub->public_key->cipher == + priv->private_key->cipher); GNUNET_assert (0 == GNUNET_memcmp (&pub_hash, &pub->public_key->pub_key_hash)); @@ -90,7 +78,20 @@ TMH_PG_insert_token_family_key (void *cls, " SELECT token_family_serial, $2, $3, $4, $5, $6, $7" " FROM merchant_token_families" " WHERE slug = $1"); - return GNUNET_PQ_eval_prepared_non_select (pg->conn, - "token_family_key_insert", - params); -}
\ No newline at end of file + { + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_string (token_family_slug), + GNUNET_PQ_query_param_blind_sign_pub (pub->public_key), + GNUNET_PQ_query_param_auto_from_type (&pub->public_key->pub_key_hash), + GNUNET_PQ_query_param_blind_sign_priv (priv->private_key), + GNUNET_PQ_query_param_timestamp (&valid_after), + GNUNET_PQ_query_param_timestamp (&valid_before), + GNUNET_PQ_query_param_string (cipher), + GNUNET_PQ_query_param_end + }; + + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "token_family_key_insert", + params); + } +} diff --git a/src/backenddb/pg_lookup_all_products.c b/src/backenddb/pg_lookup_all_products.c index b2dbfe88..1f20a996 100644 --- a/src/backenddb/pg_lookup_all_products.c +++ b/src/backenddb/pg_lookup_all_products.c @@ -22,7 +22,7 @@ #include <taler/taler_error_codes.h> #include <taler/taler_dbevents.h> #include <taler/taler_pq_lib.h> -#include "pg_lookup_products.h" +#include "pg_lookup_all_products.h" #include "pg_helper.h" /** diff --git a/src/backenddb/pg_lookup_token_family.c b/src/backenddb/pg_lookup_token_family.c index e5c9d518..943e0ee7 100644 --- a/src/backenddb/pg_lookup_token_family.c +++ b/src/backenddb/pg_lookup_token_family.c @@ -53,7 +53,6 @@ TMH_PG_lookup_token_family (void *cls, else { char *kind; - struct GNUNET_PQ_ResultSpec rs[] = { GNUNET_PQ_result_spec_string ("slug", &details->slug), @@ -77,6 +76,7 @@ TMH_PG_lookup_token_family (void *cls, &details->used), GNUNET_PQ_result_spec_end }; + enum GNUNET_DB_QueryStatus qs; check_connection (pg); PREPARE (pg, @@ -97,17 +97,15 @@ TMH_PG_lookup_token_family (void *cls, " USING (merchant_serial)" " WHERE merchant_instances.merchant_id=$1" " AND merchant_token_families.slug=$2"); - enum GNUNET_DB_QueryStatus qs; qs = GNUNET_PQ_eval_prepared_singleton_select (pg->conn, "lookup_token_family", params, rs); - if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qs) { - if (0 == strcmp(kind, "discount")) + if (0 == strcmp (kind, "discount")) details->kind = TALER_MERCHANTDB_TFK_Discount; - else if (0 == strcmp(kind, "subscription")) + else if (0 == strcmp (kind, "subscription")) details->kind = TALER_MERCHANTDB_TFK_Subscription; else { @@ -115,7 +113,6 @@ TMH_PG_lookup_token_family (void *cls, return GNUNET_DB_STATUS_HARD_ERROR; } } - return qs; } } diff --git a/src/backenddb/pg_select_account.c b/src/backenddb/pg_select_account.c index 29fda632..9d48e421 100644 --- a/src/backenddb/pg_select_account.c +++ b/src/backenddb/pg_select_account.c @@ -22,7 +22,7 @@ #include <taler/taler_error_codes.h> #include <taler/taler_dbevents.h> #include <taler/taler_pq_lib.h> -#include "pg_select_accounts.h" +#include "pg_select_account.h" #include "pg_helper.h" |