summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2022-08-04 12:52:30 +0200
committerChristian Grothoff <christian@grothoff.org>2022-08-04 12:52:30 +0200
commitc78331b6c23b471bff31b4c05a6b6e1e3e06f42a (patch)
treebfe7effbc88f7d443fe9a1a71916d933e805b7a3 /src
parent61f39f0941340f9f7f4a60ad123cda4bccbefbfe (diff)
downloadexchange-c78331b6c23b471bff31b4c05a6b6e1e3e06f42a.tar.gz
exchange-c78331b6c23b471bff31b4c05a6b6e1e3e06f42a.tar.bz2
exchange-c78331b6c23b471bff31b4c05a6b6e1e3e06f42a.zip
-fix FTBFS in taler-exchange-httpd_kyc.c
Diffstat (limited to 'src')
-rw-r--r--src/exchange/Makefile.am1
-rw-r--r--src/exchange/taler-exchange-httpd_kyc.c85
-rw-r--r--src/exchange/taler-exchange-httpd_kyc.h12
-rw-r--r--src/include/taler_kyclogic_plugin.h23
4 files changed, 71 insertions, 50 deletions
diff --git a/src/exchange/Makefile.am b/src/exchange/Makefile.am
index add8948b2..23295c13d 100644
--- a/src/exchange/Makefile.am
+++ b/src/exchange/Makefile.am
@@ -132,6 +132,7 @@ taler_exchange_httpd_SOURCES = \
taler-exchange-httpd_deposits_get.c taler-exchange-httpd_deposits_get.h \
taler-exchange-httpd_extensions.c taler-exchange-httpd_extensions.h \
taler-exchange-httpd_keys.c taler-exchange-httpd_keys.h \
+ taler-exchange-httpd_kyc.c taler-exchange-httpd_kyc.h \
taler-exchange-httpd_kyc-check.c taler-exchange-httpd_kyc-check.h \
taler-exchange-httpd_kyc-proof.c taler-exchange-httpd_kyc-proof.h \
taler-exchange-httpd_kyc-wallet.c taler-exchange-httpd_kyc-wallet.h \
diff --git a/src/exchange/taler-exchange-httpd_kyc.c b/src/exchange/taler-exchange-httpd_kyc.c
index aa1911d28..ea90c08a6 100644
--- a/src/exchange/taler-exchange-httpd_kyc.c
+++ b/src/exchange/taler-exchange-httpd_kyc.c
@@ -19,7 +19,9 @@
* @author Christian Grothoff
*/
#include "platform.h"
+#include "taler-exchange-httpd.h"
#include "taler-exchange-httpd_kyc.h"
+#include "taler_exchangedb_plugin.h"
/**
* Information about a KYC provider.
@@ -40,7 +42,7 @@ struct TEH_KycCheck
/**
* Array of @e num_providers providers that offer this type of KYC check.
*/
- struct TEH_KycProvider *providers;
+ struct TEH_KycProvider **providers;
/**
* Length of the @e providers array.
@@ -65,13 +67,13 @@ struct TEH_KycProvider
/**
* Logic to run for this provider.
*/
- struct TEH_KYCLOGIC_Plugin *logic;
+ struct TALER_KYCLOGIC_Plugin *logic;
/**
* @e provider_section_name specific details to
* pass to the @e logic functions.
*/
- struct TEH_KYCLOGIC_ProviderDetails *pd;
+ struct TALER_KYCLOGIC_ProviderDetails *pd;
/**
* Cost of running this provider's KYC.
@@ -130,12 +132,12 @@ struct TEH_KycTrigger
/**
* Array of @e num_kyc_logics KYC logic plugins we have loaded.
*/
-static struct TEH_KYCLOGIC_Plugin **kyc_logics;
+static struct TALER_KYCLOGIC_Plugin **kyc_logics;
/**
* Length of the #kyc_logics array.
*/
-static unsigned in num_kyc_logics;
+static unsigned int num_kyc_logics;
/**
* Array of @e num_kyc_checks known types of
@@ -267,11 +269,22 @@ TEH_kyc_user_type2s (enum TEH_KycUserType ut)
* @param name name of the plugin
* @return NULL on error
*/
-static struct TEH_KYCLOGIC_Plugin *
+static struct TALER_KYCLOGIC_Plugin *
load_logic (const char *name)
{
- GNUNET_break (0);
- return NULL;
+ char *lib_name;
+ struct TALER_KYCLOGIC_Plugin *plugin;
+
+ GNUNET_asprintf (&lib_name,
+ "libtaler_plugin_kyclogic_%s",
+ name);
+ plugin = GNUNET_PLUGIN_load (lib_name,
+ (void *) TEH_cfg);
+ if (NULL != plugin)
+ plugin->library_name = lib_name;
+ else
+ GNUNET_free (lib_name);
+ return plugin;
}
@@ -312,16 +325,16 @@ add_check (const char *check)
*/
static void
add_checks (char *checks,
- struct TEH_KycCheck **p_checks,
+ struct TEH_KycCheck ***p_checks,
unsigned int *num_p_checks)
{
char *sptr;
- struct TEH_KycCheck *rchecks = NULL;
+ struct TEH_KycCheck **rchecks = NULL;
unsigned int num_rchecks = 0;
for (char *tok = strtok_r (checks, " ", &sptr);
NULL != tok;
- tok = strtok_r (checks, NULL, &sptr))
+ tok = strtok_r (NULL, " ", &sptr))
{
struct TEH_KycCheck *kc;
@@ -348,6 +361,7 @@ add_provider (const char *section)
char *ut_s;
enum TEH_KycUserType ut;
char *checks;
+ struct TALER_KYCLOGIC_Plugin *lp;
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_number (TEH_cfg,
@@ -429,8 +443,8 @@ add_provider (const char *section)
&kp->provided_checks,
&kp->num_checks);
GNUNET_free (checks);
- kp->pd = lp->load (lp->cls,
- section);
+ kp->pd = lp->load_configuration (lp->cls,
+ section);
if (NULL == kp->pd)
{
GNUNET_free (kp);
@@ -462,10 +476,10 @@ add_trigger (const char *section)
enum TEH_KycTriggerEvent ot;
if (GNUNET_OK !=
- TALER_CONFIGURATION_get_value_amount (TEH_cfg,
- section,
- "THRESHOLD",
- &threshold))
+ TALER_config_get_amount (TEH_cfg,
+ section,
+ "THRESHOLD",
+ &threshold))
{
GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR,
section,
@@ -539,8 +553,8 @@ add_trigger (const char *section)
&kt->required_checks,
&kt->num_checks);
GNUNET_free (checks);
- GNUNET_array_append (kyc_checks,
- num_kyc_checks,
+ GNUNET_array_append (kyc_triggers,
+ num_kyc_triggers,
kt);
}
return GNUNET_OK;
@@ -589,11 +603,11 @@ handle_section (void *cls,
* @return -1 if p1 < p2, 0 if p1==p2, 1 if p1 > p2.
*/
static int
-sort_by_timeframe (void *p1,
- void *p2)
+sort_by_timeframe (const void *p1,
+ const void *p2)
{
- struct TEH_KycTrigger **t1 = p1;
- struct TEH_KycTrigger **t2 = p2;
+ struct TEH_KycTrigger **t1 = (struct TEH_KycTrigger **) p1;
+ struct TEH_KycTrigger **t2 = (struct TEH_KycTrigger **) p2;
if (GNUNET_TIME_relative_cmp ((*t1)->timeframe,
<,
@@ -610,7 +624,7 @@ sort_by_timeframe (void *p1,
enum GNUNET_GenericReturnValue
TEH_kyc_init (void)
{
- book ok = true;
+ bool ok = true;
GNUNET_CONFIGURATION_iterate_sections (TEH_cfg,
&handle_section,
@@ -659,7 +673,7 @@ TEH_kyc_done (void)
{
struct TEH_KycProvider *kp = kyc_providers[i];
- kp->logic->unload (kp->pd);
+ kp->logic->unload_configuration (kp->pd);
GNUNET_array_grow (kp->provided_checks,
kp->num_checks,
0);
@@ -670,9 +684,12 @@ TEH_kyc_done (void)
0);
for (unsigned int i = 0; i<num_kyc_logics; i++)
{
- struct TEH_KYCLOGIC_Plugin *lp = kyc_logics[i];
+ struct TALER_KYCLOGIC_Plugin *lp = kyc_logics[i];
+ char *lib_name = lp->library_name;
- unload_plugin (lp);
+ GNUNET_assert (NULL == GNUNET_PLUGIN_unload (lib_name,
+ lp));
+ GNUNET_free (lib_name);
}
GNUNET_array_grow (kyc_logics,
num_kyc_logics,
@@ -759,17 +776,17 @@ eval_trigger (void *cls,
{
const struct TEH_KycTrigger *kt = kyc_triggers[i];
- if (event != kt->trigger)
+ if (ttc->event != kt->trigger)
continue;
- timeframe = GNUNET_TIME_relative_max (timeframe,
- kt->timeframe);
+ duration = GNUNET_TIME_relative_max (duration,
+ kt->timeframe);
if (GNUNET_TIME_relative_cmp (kt->timeframe,
>,
duration))
{
if (bump)
ttc->start = i;
- return;
+ return GNUNET_OK;
}
if (-1 ==
TALER_amount_cmp (&ttc->total,
@@ -868,7 +885,7 @@ const char *
TEH_kyc_test_required (enum TEH_KycTriggerEvent event,
const struct TALER_PaytoHashP *h_payto,
TEH_KycAmountIterator ai,
- void *cls)
+ void *ai_cls)
{
struct TEH_KycCheck *needed[num_kyc_checks];
unsigned int needed_cnt = 0;
@@ -977,8 +994,8 @@ TEH_kyc_test_required (enum TEH_KycTriggerEvent event,
enum GNUNET_GenericReturnValue
TEH_kyc_get_logic (const char *provider_section_name,
- struct TEH_KYCLOGIC_Plugin **plugin,
- struct TEH_KYCLOGIC_ProviderDetails **pd)
+ struct TALER_KYCLOGIC_Plugin **plugin,
+ struct TALER_KYCLOGIC_ProviderDetails **pd)
{
for (unsigned int i = 0; i<num_kyc_providers; i++)
{
diff --git a/src/exchange/taler-exchange-httpd_kyc.h b/src/exchange/taler-exchange-httpd_kyc.h
index e64f9c344..cc76f5a43 100644
--- a/src/exchange/taler-exchange-httpd_kyc.h
+++ b/src/exchange/taler-exchange-httpd_kyc.h
@@ -150,7 +150,7 @@ TEH_kyc_done (void);
* #GNUNET_NO to abort iteration
* #GNUNET_SYSERR on internal error (also abort itaration)
*/
-enum GNUNET_GenericReturnValue
+typedef enum GNUNET_GenericReturnValue
(*TEH_KycAmountCallback)(void *cls,
const struct TALER_Amount *amount,
struct GNUNET_TIME_Absolute date);
@@ -171,7 +171,7 @@ enum GNUNET_GenericReturnValue
* order
* @param cb_cls closure for @a cb
*/
-void
+typedef void
(*TEH_KycAmountIterator)(void *cls,
struct GNUNET_TIME_Absolute limit,
TEH_KycAmountCallback cb,
@@ -192,14 +192,14 @@ void
* @param ai callback offered to inquire about historic
* amounts involved in this type of operation
* at the given account
- * @param cls closure for @a pi and @a ai
+ * @param ai_cls closure for @a ai
* @return NULL if no check is needed
*/
const char *
TEH_kyc_test_required (enum TEH_KycTriggerEvent event,
const struct TALER_PaytoHashP *h_payto,
TEH_KycAmountIterator ai,
- void *cls);
+ void *ai_cls);
/**
@@ -212,8 +212,8 @@ TEH_kyc_test_required (enum TEH_KycTriggerEvent event,
*/
enum GNUNET_GenericReturnValue
TEH_kyc_get_logic (const char *provider_section_name,
- struct TEH_KYCLOGIC_Plugin **plugin,
- struct TEH_KYCLOGIC_ProviderDetails **pd);
+ struct TALER_KYCLOGIC_Plugin **plugin,
+ struct TALER_KYCLOGIC_ProviderDetails **pd);
#endif
diff --git a/src/include/taler_kyclogic_plugin.h b/src/include/taler_kyclogic_plugin.h
index 303c53443..403181bf9 100644
--- a/src/include/taler_kyclogic_plugin.h
+++ b/src/include/taler_kyclogic_plugin.h
@@ -23,18 +23,19 @@
#include <jansson.h>
#include <gnunet/gnunet_util_lib.h>
+#include "taler_util.h"
/**
* Plugin-internal specification of the configuration
* of the plugin for a given KYC provider.
*/
-struct TEH_KYCLOGIC_ProviderDetails;
+struct TALER_KYCLOGIC_ProviderDetails;
/**
* Handle for an initiation operation.
*/
-struct TEH_KYCLOGIC_InitiateHandle;
+struct TALER_KYCLOGIC_InitiateHandle;
/**
@@ -48,7 +49,7 @@ struct TEH_KYCLOGIC_InitiateHandle;
* @param error_msg_hint set to additional details to return to user, NULL on success
*/
typedef void
-(*TEH_KYCLOGIC_InitiateCallback)(
+(*TALER_KYCLOGIC_InitiateCallback)(
enum TALER_ErrorCode ec,
const char *redirect_url,
const char *provider_user_id,
@@ -77,11 +78,13 @@ struct TALER_KYCLOGIC_Plugin
/**
* Load the configuration of the KYC provider.
*
+ * @param cls closure
* @param provider_section_name configuration section to parse
* @return NULL if configuration is invalid
*/
- struct TEH_KYCLOGIC_ProviderDetails *
- (*load_configuration)(const char *provider_section_name);
+ struct TALER_KYCLOGIC_ProviderDetails *
+ (*load_configuration)(void *cls,
+ const char *provider_section_name);
/**
* Release configuration resources previously loaded
@@ -89,7 +92,7 @@ struct TALER_KYCLOGIC_Plugin
* @param[in] pd configuration to release
*/
void
- (*unload_configuration)(struct TEH_KYCLOGIC_ProviderDetails *pd);
+ (*unload_configuration)(struct TALER_KYCLOGIC_ProviderDetails *pd);
/**
@@ -100,11 +103,11 @@ struct TALER_KYCLOGIC_Plugin
* @param account_id which account to trigger process for
* @return handle to cancel operation early
*/
- struct TEH_KYCLOGIC_InitiateHandle *
+ struct TALER_KYCLOGIC_InitiateHandle *
(*initiate)(void *cls,
- const struct TEH_KYCLOGIC_ProviderDetails *pd,
+ const struct TALER_KYCLOGIC_ProviderDetails *pd,
const struct TALER_PaytoHashP *account_id,
- TEH_KYCLOGIC_InitiateCallback cb,
+ TALER_KYCLOGIC_InitiateCallback cb,
void *cb_cls);
/**
@@ -113,7 +116,7 @@ struct TALER_KYCLOGIC_Plugin
* @param[in] ih handle of operation to cancel
*/
void
- (*initiate_cancel) (struct TEH_KYCLOGIC_InitiateHandle *ih);
+ (*initiate_cancel) (struct TALER_KYCLOGIC_InitiateHandle *ih);
// FIXME: add callback pair for kyc_proof