commit 2db283d64894a8d7d6cb55441c8fdd6ff255d6b5
parent 000fb7d39c7e1dc233f95e25846397bf1cf52565
Author: Christian Grothoff <christian@grothoff.org>
Date: Sat, 11 Jul 2026 11:07:51 +0200
apply result closure transformation for improved type safety
Diffstat:
10 files changed, 122 insertions(+), 59 deletions(-)
diff --git a/src/include/donau_service.h b/src/include/donau_service.h
@@ -296,9 +296,15 @@ struct DONAU_KeysResponse
* reference counter of 1. Must be freed by callee
* using #DONAU_keys_decref(). NULL on failure.
*/
+#ifndef DONAU_GET_KEYS_RESULT_CLOSURE
+/**
+ * Type of the closure used by the #DONAU_GetKeysCallback.
+ */
+#define DONAU_GET_KEYS_RESULT_CLOSURE void
+#endif
typedef void
(*DONAU_GetKeysCallback) (
- void *cls,
+ DONAU_GET_KEYS_RESULT_CLOSURE *cls,
const struct DONAU_KeysResponse *kr,
struct DONAU_Keys *keys);
@@ -328,7 +334,7 @@ DONAU_get_keys (
struct GNUNET_CURL_Context *ctx,
const char *url,
DONAU_GetKeysCallback cert_cb,
- void *cert_cb_cls);
+ DONAU_GET_KEYS_RESULT_CLOSURE *cert_cb_cls);
/**
@@ -556,9 +562,15 @@ struct DONAU_BatchIssueResponse
* @param cls closure
* @param dr response details
*/
+#ifndef DONAU_BATCH_ISSUE_RECEIPTS_RESULT_CLOSURE
+/**
+ * Type of the closure used by the #DONAU_BatchIssueReceiptsCallback.
+ */
+#define DONAU_BATCH_ISSUE_RECEIPTS_RESULT_CLOSURE void
+#endif
typedef void
(*DONAU_BatchIssueReceiptsCallback) (
- void *cls,
+ DONAU_BATCH_ISSUE_RECEIPTS_RESULT_CLOSURE *cls,
const struct DONAU_BatchIssueResponse*dr);
@@ -597,7 +609,7 @@ DONAU_charity_issue_receipt (
size_t num_bkp,
const struct DONAU_BlindedUniqueDonorIdentifierKeyPair *bkp,
DONAU_BatchIssueReceiptsCallback cb,
- void *cb_cls);
+ DONAU_BATCH_ISSUE_RECEIPTS_RESULT_CLOSURE *cb_cls);
/**
* Cancel a batch issue receipt request. This function cannot be used
@@ -652,9 +664,16 @@ struct DONAU_DonorReceiptsToStatementResult
* @param cls closure
* @param dr response details
*/
+#ifndef DONAU_SUBMIT_RECEIPTS_RESULT_CLOSURE
+/**
+ * Type of the closure used by the
+ * #DONAU_DonorReceiptsToStatementResultCallback.
+ */
+#define DONAU_SUBMIT_RECEIPTS_RESULT_CLOSURE void
+#endif
typedef void
(*DONAU_DonorReceiptsToStatementResultCallback) (
- void *cls,
+ DONAU_SUBMIT_RECEIPTS_RESULT_CLOSURE *cls,
const struct DONAU_DonorReceiptsToStatementResult *dr);
@@ -691,7 +710,7 @@ DONAU_donor_receipts_to_statement (
const uint64_t year,
const struct DONAU_HashDonorTaxId *h_donor_tax_id,
DONAU_DonorReceiptsToStatementResultCallback cb,
- void *cls);
+ DONAU_SUBMIT_RECEIPTS_RESULT_CLOSURE *cls);
/**
* Cancel a batch permission request. This function cannot be used
@@ -762,9 +781,16 @@ struct DONAU_DonationStatementResponse
* @param cls closure
* @param dr response details
*/
+#ifndef DONAU_GET_DONATION_STATEMENT_RESULT_CLOSURE
+/**
+ * Type of the closure used by the
+ * #DONAU_GetDonationStatmentResponseCallback.
+ */
+#define DONAU_GET_DONATION_STATEMENT_RESULT_CLOSURE void
+#endif
typedef void
(*DONAU_GetDonationStatmentResponseCallback) (
- void *cls,
+ DONAU_GET_DONATION_STATEMENT_RESULT_CLOSURE *cls,
const struct DONAU_DonationStatementResponse *dr);
@@ -791,7 +817,7 @@ DONAU_donation_statement_get (
const uint64_t year,
const struct DONAU_HashDonorTaxId *h_donor_tax_id,
DONAU_GetDonationStatmentResponseCallback cb,
- void *cb_cls);
+ DONAU_GET_DONATION_STATEMENT_RESULT_CLOSURE *cb_cls);
/**
* Cancel a batch permission request. This function cannot be used
@@ -860,9 +886,15 @@ struct DONAU_CsRBatchIssueResponse
* @param cls closure
* @param csrr response details
*/
+#ifndef DONAU_CSR_BATCH_ISSUE_RESULT_CLOSURE
+/**
+ * Type of the closure used by the #DONAU_CsRBatchIssueCallback.
+ */
+#define DONAU_CSR_BATCH_ISSUE_RESULT_CLOSURE void
+#endif
typedef void
(*DONAU_CsRBatchIssueCallback) (
- void *cls,
+ DONAU_CSR_BATCH_ISSUE_RESULT_CLOSURE *cls,
const struct DONAU_CsRBatchIssueResponse *csrr);
@@ -886,7 +918,7 @@ DONAU_csr_issue (
const struct DONAU_DonationUnitPublicKey *pk,
const struct GNUNET_CRYPTO_CsSessionNonce *nonce,
DONAU_CsRBatchIssueCallback cb,
- void *cb_cls);
+ DONAU_CSR_BATCH_ISSUE_RESULT_CLOSURE *cb_cls);
/**
@@ -985,9 +1017,15 @@ struct DONAU_GetCharitiesResponse
* @param cls closure
* @param rs HTTP response data
*/
+#ifndef DONAU_GET_CHARITIES_RESULT_CLOSURE
+/**
+ * Type of the closure used by the #DONAU_GetCharitiesResponseCallback.
+ */
+#define DONAU_GET_CHARITIES_RESULT_CLOSURE void
+#endif
typedef void
(*DONAU_GetCharitiesResponseCallback) (
- void *cls,
+ DONAU_GET_CHARITIES_RESULT_CLOSURE *cls,
const struct DONAU_GetCharitiesResponse *rs);
@@ -1013,7 +1051,7 @@ DONAU_charities_get (
const char *url,
const struct DONAU_BearerToken *bearer,
DONAU_GetCharitiesResponseCallback cb,
- void *cb_cls);
+ DONAU_GET_CHARITIES_RESULT_CLOSURE *cb_cls);
/**
@@ -1117,9 +1155,15 @@ struct DONAU_GetCharityResponse
* @param cls closure
* @param rs HTTP response data
*/
+#ifndef DONAU_GET_CHARITY_RESULT_CLOSURE
+/**
+ * Type of the closure used by the #DONAU_GetCharityResponseCallback.
+ */
+#define DONAU_GET_CHARITY_RESULT_CLOSURE void
+#endif
typedef void
(*DONAU_GetCharityResponseCallback) (
- void *cls,
+ DONAU_GET_CHARITY_RESULT_CLOSURE *cls,
const struct DONAU_GetCharityResponse *rs);
@@ -1147,7 +1191,7 @@ DONAU_charity_get (
uint64_t id,
const struct DONAU_CharityPrivateKeyP *charity_priv,
DONAU_GetCharityResponseCallback cb,
- void *cb_cls);
+ DONAU_GET_CHARITY_RESULT_CLOSURE *cb_cls);
/**
@@ -1212,9 +1256,15 @@ struct DONAU_PostCharityResponse
* @param cls closure
* @param rs HTTP response data
*/
+#ifndef DONAU_POST_CHARITY_RESULT_CLOSURE
+/**
+ * Type of the closure used by the #DONAU_PostCharityResponseCallback.
+ */
+#define DONAU_POST_CHARITY_RESULT_CLOSURE void
+#endif
typedef void
(*DONAU_PostCharityResponseCallback) (
- void *cls,
+ DONAU_POST_CHARITY_RESULT_CLOSURE *cls,
const struct DONAU_PostCharityResponse *rs);
@@ -1248,7 +1298,7 @@ DONAU_charity_post (
const struct DONAU_CharityPublicKeyP *charity_pub,
const struct DONAU_BearerToken *bearer,
DONAU_PostCharityResponseCallback cb,
- void *cb_cls);
+ DONAU_POST_CHARITY_RESULT_CLOSURE *cb_cls);
/**
* Cancel a charity Post request. This function cannot be used
@@ -1291,9 +1341,15 @@ struct DONAU_PatchCharityResponse
* @param cls closure
* @param rs HTTP response data
*/
+#ifndef DONAU_PATCH_CHARITY_RESULT_CLOSURE
+/**
+ * Type of the closure used by the #DONAU_PatchCharityResponseCallback.
+ */
+#define DONAU_PATCH_CHARITY_RESULT_CLOSURE void
+#endif
typedef void
(*DONAU_PatchCharityResponseCallback) (
- void *cls,
+ DONAU_PATCH_CHARITY_RESULT_CLOSURE *cls,
const struct DONAU_PatchCharityResponse *rs);
@@ -1329,7 +1385,7 @@ DONAU_charity_patch (
const struct DONAU_CharityPublicKeyP *charity_pub,
const struct DONAU_BearerToken *bearer,
DONAU_PatchCharityResponseCallback cb,
- void *cb_cls);
+ DONAU_PATCH_CHARITY_RESULT_CLOSURE *cb_cls);
/**
* Cancel a charity Patch request. This function cannot be used
@@ -1371,9 +1427,15 @@ struct DONAU_DeleteCharityResponse
* @param cls closure
* @param rs HTTP response data
*/
+#ifndef DONAU_DELETE_CHARITY_RESULT_CLOSURE
+/**
+ * Type of the closure used by the #DONAU_DeleteCharityResponseCallback.
+ */
+#define DONAU_DELETE_CHARITY_RESULT_CLOSURE void
+#endif
typedef void
(*DONAU_DeleteCharityResponseCallback) (
- void *cls,
+ DONAU_DELETE_CHARITY_RESULT_CLOSURE *cls,
const struct DONAU_DeleteCharityResponse *rs);
@@ -1401,7 +1463,7 @@ DONAU_charity_delete (
const uint64_t id,
const struct DONAU_BearerToken *bearer,
DONAU_DeleteCharityResponseCallback cb,
- void *cb_cls);
+ DONAU_DELETE_CHARITY_RESULT_CLOSURE *cb_cls);
/**
* Cancel a charity Delete request. This function cannot be used
diff --git a/src/testing/testing_api_cmd_charities_get.c b/src/testing/testing_api_cmd_charities_get.c
@@ -25,6 +25,8 @@
#include <taler/taler_json_lib.h>
#include <gnunet/gnunet_curl_lib.h>
#include <taler/taler_testing_lib.h>
+struct StatusState;
+#define DONAU_GET_CHARITIES_RESULT_CLOSURE struct StatusState
#include "donau_testing_lib.h"
@@ -60,15 +62,13 @@ struct StatusState
* Check that the reserve balance and HTTP response code are
* both acceptable.
*
- * @param cls closure.
+ * @param ss closure.
* @param gcr HTTP response details
*/
static void
-charities_status_cb (void *cls,
+charities_status_cb (struct StatusState *ss,
const struct DONAU_GetCharitiesResponse *gcr)
{
- struct StatusState *ss = cls;
-
ss->cgh = NULL;
if (ss->expected_response_code != gcr->hr.http_status)
{
diff --git a/src/testing/testing_api_cmd_charity_delete.c b/src/testing/testing_api_cmd_charity_delete.c
@@ -25,6 +25,8 @@
#include <taler/taler_json_lib.h>
#include <gnunet/gnunet_curl_lib.h>
#include <taler/taler_testing_lib.h>
+struct StatusState;
+#define DONAU_DELETE_CHARITY_RESULT_CLOSURE struct StatusState
#include "donau_testing_lib.h"
@@ -70,16 +72,13 @@ struct StatusState
* Check that the reserve balance and HTTP response code are
* both acceptable.
*
- * @param cls closure.
+ * @param ss closure.
* @param dcr HTTP response details
*/
static void
-charity_status_cb (void *cls,
+charity_status_cb (struct StatusState *ss,
const struct DONAU_DeleteCharityResponse *dcr)
{
- struct StatusState *ss = cls;
-
-
ss->cgh = NULL;
if (ss->expected_response_code != dcr->hr.http_status)
{
diff --git a/src/testing/testing_api_cmd_charity_get.c b/src/testing/testing_api_cmd_charity_get.c
@@ -26,6 +26,8 @@
#include <taler/taler_json_lib.h>
#include <gnunet/gnunet_curl_lib.h>
#include <taler/taler_testing_lib.h>
+struct StatusState;
+#define DONAU_GET_CHARITY_RESULT_CLOSURE struct StatusState
#include "donau_testing_lib.h"
@@ -65,15 +67,13 @@ struct StatusState
* Check that the reserve balance and HTTP response code are
* both acceptable.
*
- * @param cls closure.
+ * @param ss closure.
* @param gcr HTTP response details
*/
static void
-charity_status_cb (void *cls,
+charity_status_cb (struct StatusState *ss,
const struct DONAU_GetCharityResponse *gcr)
{
- struct StatusState *ss = cls;
-
ss->cgh = NULL;
if (ss->expected_response_code != gcr->hr.http_status)
{
diff --git a/src/testing/testing_api_cmd_charity_patch.c b/src/testing/testing_api_cmd_charity_patch.c
@@ -25,6 +25,8 @@
#include <taler/taler_json_lib.h>
#include <gnunet/gnunet_curl_lib.h>
#include <taler/taler_testing_lib.h>
+struct CharityPatchState;
+#define DONAU_PATCH_CHARITY_RESULT_CLOSURE struct CharityPatchState
#include "donau_testing_lib.h"
@@ -93,15 +95,13 @@ struct CharityPatchState
/**
* Check HTTP response for the PATCH request and advance the interpreter on success.
*
- * @param cls closure
+ * @param ps closure
* @param resp HTTP response details
*/
static void
-charity_patch_cb (void *cls,
+charity_patch_cb (struct CharityPatchState *ps,
const struct DONAU_PatchCharityResponse *resp)
{
- struct CharityPatchState *ps = cls;
-
ps->cph = NULL;
if (ps->expected_response_code != resp->hr.http_status)
{
diff --git a/src/testing/testing_api_cmd_charity_post.c b/src/testing/testing_api_cmd_charity_post.c
@@ -25,6 +25,8 @@
#include <taler/taler_json_lib.h>
#include <gnunet/gnunet_curl_lib.h>
#include <taler/taler_testing_lib.h>
+struct StatusState;
+#define DONAU_POST_CHARITY_RESULT_CLOSURE struct StatusState
#include "donau_testing_lib.h"
@@ -90,15 +92,13 @@ struct StatusState
* Check that the reserve balance and HTTP response code are
* both acceptable.
*
- * @param cls closure.
+ * @param ss closure.
* @param gcr HTTP response details
*/
static void
-charity_status_cb (void *cls,
+charity_status_cb (struct StatusState *ss,
const struct DONAU_PostCharityResponse *gcr)
{
- struct StatusState *ss = cls;
-
ss->cph = NULL;
if (ss->expected_response_code != gcr->hr.http_status)
{
diff --git a/src/testing/testing_api_cmd_donation_statement_get.c b/src/testing/testing_api_cmd_donation_statement_get.c
@@ -26,6 +26,8 @@
#include <taler/taler_json_lib.h>
#include <gnunet/gnunet_curl_lib.h>
#include <taler/taler_testing_lib.h>
+struct StatusState;
+#define DONAU_GET_DONATION_STATEMENT_RESULT_CLOSURE struct StatusState
#include "donau_testing_lib.h"
@@ -65,15 +67,13 @@ struct StatusState
* Check that the reserve balance and HTTP response code are
* both acceptable.
*
- * @param cls closure.
+ * @param ss closure.
* @param dsr HTTP response details
*/
static void
-donation_statement_status_cb (void *cls,
+donation_statement_status_cb (struct StatusState *ss,
const struct DONAU_DonationStatementResponse *dsr)
{
- struct StatusState *ss = cls;
-
ss->dsgh = NULL;
if (ss->expected_response_code != dsr->hr.http_status)
{
diff --git a/src/testing/testing_api_cmd_get_donau.c b/src/testing/testing_api_cmd_get_donau.c
@@ -26,6 +26,8 @@
#include <taler/taler_json_lib.h>
#include <gnunet/gnunet_curl_lib.h>
#include <taler/taler_testing_lib.h>
+struct GetDonauState;
+#define DONAU_GET_KEYS_RESULT_CLOSURE struct GetDonauState
#include "donau_testing_lib.h"
#include "donau_service.h"
@@ -65,16 +67,15 @@ struct GetDonauState
/**
* Function called with information about what keys the donau is using.
*
- * @param cls closure
+ * @param ges closure
* @param kr response from /keys
* @param[in] keys the keys of the donau
*/
static void
-cert_cb (void *cls,
+cert_cb (struct GetDonauState *ges,
const struct DONAU_KeysResponse *kr,
struct DONAU_Keys *keys)
{
- struct GetDonauState *ges = cls;
const struct DONAU_HttpResponse *hr = &kr->hr;
struct TALER_TESTING_Interpreter *is = ges->is;
diff --git a/src/testing/testing_api_cmd_issue_receipts.c b/src/testing/testing_api_cmd_issue_receipts.c
@@ -25,6 +25,10 @@
#include <taler/taler_json_lib.h>
#include <gnunet/gnunet_curl_lib.h>
#include <taler/taler_testing_lib.h>
+struct StatusState;
+struct CSR_Data;
+#define DONAU_BATCH_ISSUE_RECEIPTS_RESULT_CLOSURE struct StatusState
+#define DONAU_CSR_BATCH_ISSUE_RESULT_CLOSURE struct CSR_Data
#include "donau_testing_lib.h"
@@ -167,15 +171,13 @@ struct CSR_Data
* Check that the reserve balance and HTTP response code are
* both acceptable.
*
- * @param cls closure.
+ * @param ss closure.
* @param biresp HTTP response details
*/
static void
-issue_receipts_status_cb (void *cls,
+issue_receipts_status_cb (struct StatusState *ss,
const struct DONAU_BatchIssueResponse *biresp)
{
- struct StatusState *ss = cls;
-
ss->birh = NULL;
if (ss->expected_response_code != biresp->hr.http_status)
{
@@ -262,15 +264,14 @@ phase_two (void *cls)
/**
* Function called when stage 1 of CS issue is finished (request r_pub's)
*
- * @param cls the `struct CSR_Data *`
+ * @param csr_data the `struct CSR_Data *`
* @param csrresp replies from the /csr-issue request
*/
static void
cs_stage_two_callback (
- void *cls,
+ struct CSR_Data *csr_data,
const struct DONAU_CsRBatchIssueResponse *csrresp)
{
- struct CSR_Data *csr_data = cls;
struct DONAU_BlindedUniqueDonorIdentifier *blinded_udi =
&csr_data->ss->bkps[csr_data->position].blinded_udi;
diff --git a/src/testing/testing_api_cmd_submit_receipts.c b/src/testing/testing_api_cmd_submit_receipts.c
@@ -25,6 +25,8 @@
#include <taler/taler_json_lib.h>
#include <gnunet/gnunet_curl_lib.h>
#include <taler/taler_testing_lib.h>
+struct StatusState;
+#define DONAU_SUBMIT_RECEIPTS_RESULT_CLOSURE struct StatusState
#include "donau_testing_lib.h"
@@ -85,16 +87,14 @@ struct StatusState
* Check that the reserve balance and HTTP response code are
* both acceptable.
*
- * @param cls closure.
+ * @param ss closure.
* @param rtsresp HTTP response details
*/
static void
-submit_receipts_status_cb (void *cls,
+submit_receipts_status_cb (struct StatusState *ss,
const struct
DONAU_DonorReceiptsToStatementResult *rtsresp)
{
- struct StatusState *ss = cls;
-
ss->bsrh = NULL;
if (ss->expected_response_code != rtsresp->hr.http_status)
{