move common logic to parse currency into libtalerutil
This commit is contained in:
parent
d7cfb11fc6
commit
4322bbf2f1
@ -455,14 +455,9 @@ auditor_serve_process_config ()
|
|||||||
return GNUNET_SYSERR;
|
return GNUNET_SYSERR;
|
||||||
}
|
}
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
GNUNET_CONFIGURATION_get_value_string (cfg,
|
TALER_config_get_currency (cfg,
|
||||||
"TALER",
|
¤cy))
|
||||||
"CURRENCY",
|
|
||||||
¤cy))
|
|
||||||
{
|
{
|
||||||
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
|
|
||||||
"TALER",
|
|
||||||
"CURRENCY");
|
|
||||||
return GNUNET_SYSERR;
|
return GNUNET_SYSERR;
|
||||||
}
|
}
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
|
@ -5291,14 +5291,9 @@ run (void *cls,
|
|||||||
TALER_B2S (&master_pub));
|
TALER_B2S (&master_pub));
|
||||||
|
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
GNUNET_CONFIGURATION_get_value_string (cfg,
|
TALER_config_get_currency (cfg,
|
||||||
"taler",
|
¤cy))
|
||||||
"CURRENCY",
|
|
||||||
¤cy))
|
|
||||||
{
|
{
|
||||||
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
|
|
||||||
"taler",
|
|
||||||
"CURRENCY");
|
|
||||||
global_ret = 1;
|
global_ret = 1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -2178,14 +2178,9 @@ run (void *cls,
|
|||||||
} /* end of -m not given */
|
} /* end of -m not given */
|
||||||
|
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
GNUNET_CONFIGURATION_get_value_string (cfg,
|
TALER_config_get_currency (cfg,
|
||||||
"taler",
|
¤cy))
|
||||||
"CURRENCY",
|
|
||||||
¤cy))
|
|
||||||
{
|
{
|
||||||
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
|
|
||||||
"taler",
|
|
||||||
"CURRENCY");
|
|
||||||
global_ret = 1;
|
global_ret = 1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -3197,14 +3197,9 @@ libtaler_plugin_auditordb_postgres_init (void *cls)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
GNUNET_CONFIGURATION_get_value_string (cfg,
|
TALER_config_get_currency (cfg,
|
||||||
"taler",
|
&pg->currency))
|
||||||
"CURRENCY",
|
|
||||||
&pg->currency))
|
|
||||||
{
|
{
|
||||||
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
|
|
||||||
"taler",
|
|
||||||
"CURRENCY");
|
|
||||||
GNUNET_free (pg);
|
GNUNET_free (pg);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,7 @@ taler_fakebank_run_SOURCES = \
|
|||||||
taler-fakebank-run.c
|
taler-fakebank-run.c
|
||||||
taler_fakebank_run_LDADD = \
|
taler_fakebank_run_LDADD = \
|
||||||
libtalerfakebank.la \
|
libtalerfakebank.la \
|
||||||
|
$(top_builddir)/src/util/libtalerutil.la \
|
||||||
-lgnunetutil
|
-lgnunetutil
|
||||||
|
|
||||||
taler_bank_transfer_SOURCES = \
|
taler_bank_transfer_SOURCES = \
|
||||||
|
@ -48,26 +48,10 @@ run (void *cls,
|
|||||||
(void) cls;
|
(void) cls;
|
||||||
(void) args;
|
(void) args;
|
||||||
(void) cfgfile;
|
(void) cfgfile;
|
||||||
(void) cfg;
|
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
GNUNET_CONFIGURATION_get_value_string (cfg,
|
TALER_config_get_currency (cfg,
|
||||||
"taler",
|
¤cy_string))
|
||||||
"CURRENCY",
|
|
||||||
¤cy_string))
|
|
||||||
{
|
{
|
||||||
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
|
|
||||||
"taler",
|
|
||||||
"CURRENCY");
|
|
||||||
ret = 1;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (strlen (currency_string) >= TALER_CURRENCY_LEN)
|
|
||||||
{
|
|
||||||
GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR,
|
|
||||||
"taler",
|
|
||||||
"CURRENCY",
|
|
||||||
"Value is too long");
|
|
||||||
GNUNET_free (currency_string);
|
|
||||||
ret = 1;
|
ret = 1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -831,25 +831,9 @@ main (int argc,
|
|||||||
return BAD_CONFIG_FILE;
|
return BAD_CONFIG_FILE;
|
||||||
}
|
}
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
GNUNET_CONFIGURATION_get_value_string (cfg,
|
TALER_config_get_currency (cfg,
|
||||||
"taler",
|
¤cy))
|
||||||
"currency",
|
|
||||||
¤cy))
|
|
||||||
{
|
{
|
||||||
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
|
|
||||||
"taler",
|
|
||||||
"currency");
|
|
||||||
GNUNET_CONFIGURATION_destroy (cfg);
|
|
||||||
GNUNET_free (cfg_filename);
|
|
||||||
return BAD_CONFIG_FILE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (strlen (currency) >= TALER_CURRENCY_LEN)
|
|
||||||
{
|
|
||||||
GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR,
|
|
||||||
"taler",
|
|
||||||
"CURRENCY",
|
|
||||||
"Value is too long");
|
|
||||||
GNUNET_CONFIGURATION_destroy (cfg);
|
GNUNET_CONFIGURATION_destroy (cfg);
|
||||||
GNUNET_free (cfg_filename);
|
GNUNET_free (cfg_filename);
|
||||||
return BAD_CONFIG_FILE;
|
return BAD_CONFIG_FILE;
|
||||||
|
@ -772,7 +772,7 @@ create_denomkey_issue (
|
|||||||
GNUNET_assert (NULL != dki->denom_priv.rsa_private_key);
|
GNUNET_assert (NULL != dki->denom_priv.rsa_private_key);
|
||||||
dki->denom_pub.rsa_public_key
|
dki->denom_pub.rsa_public_key
|
||||||
= GNUNET_CRYPTO_rsa_private_key_get_public (
|
= GNUNET_CRYPTO_rsa_private_key_get_public (
|
||||||
dki->denom_priv.rsa_private_key);
|
dki->denom_priv.rsa_private_key);
|
||||||
GNUNET_CRYPTO_rsa_public_key_hash (dki->denom_pub.rsa_public_key,
|
GNUNET_CRYPTO_rsa_public_key_hash (dki->denom_pub.rsa_public_key,
|
||||||
&dki->issue.properties.denom_hash);
|
&dki->issue.properties.denom_hash);
|
||||||
dki->issue.properties.master = master_public_key;
|
dki->issue.properties.master = master_public_key;
|
||||||
@ -1174,14 +1174,9 @@ run (void *cls,
|
|||||||
(void) cfgfile;
|
(void) cfgfile;
|
||||||
kcfg = cfg;
|
kcfg = cfg;
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
GNUNET_CONFIGURATION_get_value_string (cfg,
|
TALER_config_get_currency (cfg,
|
||||||
"taler",
|
¤cy))
|
||||||
"CURRENCY",
|
|
||||||
¤cy))
|
|
||||||
{
|
{
|
||||||
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
|
|
||||||
"taler",
|
|
||||||
"CURRENCY");
|
|
||||||
global_ret = 1;
|
global_ret = 1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -758,31 +758,6 @@ exchange_serve_process_config ()
|
|||||||
"REVOCATION_DIR");
|
"REVOCATION_DIR");
|
||||||
return GNUNET_SYSERR;
|
return GNUNET_SYSERR;
|
||||||
}
|
}
|
||||||
{
|
|
||||||
char *currency_string;
|
|
||||||
|
|
||||||
if (GNUNET_OK !=
|
|
||||||
GNUNET_CONFIGURATION_get_value_string (cfg,
|
|
||||||
"taler",
|
|
||||||
"CURRENCY",
|
|
||||||
¤cy_string))
|
|
||||||
{
|
|
||||||
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
|
|
||||||
"taler",
|
|
||||||
"CURRENCY");
|
|
||||||
return GNUNET_SYSERR;
|
|
||||||
}
|
|
||||||
if (strlen (currency_string) >= TALER_CURRENCY_LEN)
|
|
||||||
{
|
|
||||||
GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR,
|
|
||||||
"taler",
|
|
||||||
"CURRENCY",
|
|
||||||
"Value is too long");
|
|
||||||
GNUNET_free (currency_string);
|
|
||||||
return GNUNET_SYSERR;
|
|
||||||
}
|
|
||||||
GNUNET_free (currency_string);
|
|
||||||
}
|
|
||||||
{
|
{
|
||||||
char *master_public_key_str;
|
char *master_public_key_str;
|
||||||
|
|
||||||
|
@ -100,11 +100,6 @@ static struct GNUNET_CURL_Context *ctx;
|
|||||||
*/
|
*/
|
||||||
static struct GNUNET_CURL_RescheduleContext *rc;
|
static struct GNUNET_CURL_RescheduleContext *rc;
|
||||||
|
|
||||||
/**
|
|
||||||
* Which currency is used by this exchange?
|
|
||||||
*/
|
|
||||||
static char *exchange_currency_string;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The exchange's configuration (global)
|
* The exchange's configuration (global)
|
||||||
*/
|
*/
|
||||||
@ -177,8 +172,6 @@ static struct TALER_BANK_CreditHistoryHandle *hh;
|
|||||||
static void
|
static void
|
||||||
shutdown_task (void *cls)
|
shutdown_task (void *cls)
|
||||||
{
|
{
|
||||||
struct WireAccount *wa;
|
|
||||||
|
|
||||||
(void) cls;
|
(void) cls;
|
||||||
if (NULL != hh)
|
if (NULL != hh)
|
||||||
{
|
{
|
||||||
@ -202,14 +195,18 @@ shutdown_task (void *cls)
|
|||||||
}
|
}
|
||||||
TALER_EXCHANGEDB_plugin_unload (db_plugin);
|
TALER_EXCHANGEDB_plugin_unload (db_plugin);
|
||||||
db_plugin = NULL;
|
db_plugin = NULL;
|
||||||
while (NULL != (wa = wa_head))
|
|
||||||
{
|
{
|
||||||
GNUNET_CONTAINER_DLL_remove (wa_head,
|
struct WireAccount *wa;
|
||||||
wa_tail,
|
|
||||||
wa);
|
while (NULL != (wa = wa_head))
|
||||||
TALER_BANK_auth_free (&wa->auth);
|
{
|
||||||
GNUNET_free (wa->section_name);
|
GNUNET_CONTAINER_DLL_remove (wa_head,
|
||||||
GNUNET_free (wa);
|
wa_tail,
|
||||||
|
wa);
|
||||||
|
TALER_BANK_auth_free (&wa->auth);
|
||||||
|
GNUNET_free (wa->section_name);
|
||||||
|
GNUNET_free (wa);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
wa_pos = NULL;
|
wa_pos = NULL;
|
||||||
last_row_off = 0;
|
last_row_off = 0;
|
||||||
@ -259,28 +256,8 @@ add_account_cb (void *cls,
|
|||||||
* @return #GNUNET_OK on success
|
* @return #GNUNET_OK on success
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
exchange_serve_process_config ()
|
exchange_serve_process_config (void)
|
||||||
{
|
{
|
||||||
if (GNUNET_OK !=
|
|
||||||
GNUNET_CONFIGURATION_get_value_string (cfg,
|
|
||||||
"taler",
|
|
||||||
"CURRENCY",
|
|
||||||
&exchange_currency_string))
|
|
||||||
{
|
|
||||||
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
|
|
||||||
"taler",
|
|
||||||
"CURRENCY");
|
|
||||||
return GNUNET_SYSERR;
|
|
||||||
}
|
|
||||||
if (strlen (exchange_currency_string) >= TALER_CURRENCY_LEN)
|
|
||||||
{
|
|
||||||
fprintf (stderr,
|
|
||||||
"Currency `%s' longer than the allowed limit of %u characters.",
|
|
||||||
exchange_currency_string,
|
|
||||||
(unsigned int) TALER_CURRENCY_LEN);
|
|
||||||
return GNUNET_SYSERR;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (NULL ==
|
if (NULL ==
|
||||||
(db_plugin = TALER_EXCHANGEDB_plugin_load (cfg)))
|
(db_plugin = TALER_EXCHANGEDB_plugin_load (cfg)))
|
||||||
{
|
{
|
||||||
|
@ -7230,14 +7230,9 @@ libtaler_plugin_exchangedb_postgres_init (void *cls)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
GNUNET_CONFIGURATION_get_value_string (cfg,
|
TALER_config_get_currency (cfg,
|
||||||
"taler",
|
&pg->currency))
|
||||||
"CURRENCY",
|
|
||||||
&pg->currency))
|
|
||||||
{
|
{
|
||||||
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
|
|
||||||
"taler",
|
|
||||||
"CURRENCY");
|
|
||||||
GNUNET_free (pg->sql_dir);
|
GNUNET_free (pg->sql_dir);
|
||||||
GNUNET_free (pg);
|
GNUNET_free (pg);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -137,6 +137,19 @@ TALER_config_get_amount (const struct GNUNET_CONFIGURATION_Handle *cfg,
|
|||||||
struct TALER_Amount *denom);
|
struct TALER_Amount *denom);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load our currency from the @a cfg (in section [taler]
|
||||||
|
* the option "CURRENCY").
|
||||||
|
*
|
||||||
|
* @param cfg configuration to use
|
||||||
|
* @param[out] currency where to write the result
|
||||||
|
* @return #GNUNET_OK on success, #GNUNET_SYSERR on failure
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
TALER_config_get_currency (const struct GNUNET_CONFIGURATION_Handle *cfg,
|
||||||
|
char **currency);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allow user to specify an amount on the command line.
|
* Allow user to specify an amount on the command line.
|
||||||
*
|
*
|
||||||
|
@ -127,24 +127,9 @@ TALER_TESTING_run_with_fakebank (struct TALER_TESTING_Interpreter *is,
|
|||||||
char *currency;
|
char *currency;
|
||||||
|
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
GNUNET_CONFIGURATION_get_value_string (is->cfg,
|
TALER_config_get_currency (is->cfg,
|
||||||
"taler",
|
¤cy))
|
||||||
"CURRENCY",
|
|
||||||
¤cy))
|
|
||||||
{
|
{
|
||||||
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
|
|
||||||
"taler",
|
|
||||||
"CURRENCY");
|
|
||||||
is->result = GNUNET_SYSERR;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (strlen (currency) >= TALER_CURRENCY_LEN)
|
|
||||||
{
|
|
||||||
GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR,
|
|
||||||
"taler",
|
|
||||||
"CURRENCY",
|
|
||||||
"Value is too long");
|
|
||||||
GNUNET_free (currency);
|
|
||||||
is->result = GNUNET_SYSERR;
|
is->result = GNUNET_SYSERR;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -55,3 +55,40 @@ TALER_config_get_amount (const struct GNUNET_CONFIGURATION_Handle *cfg,
|
|||||||
GNUNET_free (str);
|
GNUNET_free (str);
|
||||||
return GNUNET_OK;
|
return GNUNET_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load our currency from the @a cfg (in section [taler]
|
||||||
|
* the option "CURRENCY").
|
||||||
|
*
|
||||||
|
* @param cfg configuration to use
|
||||||
|
* @param[out] currency where to write the result
|
||||||
|
* @return #GNUNET_OK on success, #GNUNET_SYSERR on failure
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
TALER_config_get_currency (const struct GNUNET_CONFIGURATION_Handle *cfg,
|
||||||
|
char **currency)
|
||||||
|
{
|
||||||
|
if (GNUNET_OK !=
|
||||||
|
GNUNET_CONFIGURATION_get_value_string (cfg,
|
||||||
|
"taler",
|
||||||
|
"CURRENCY",
|
||||||
|
currency))
|
||||||
|
{
|
||||||
|
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
|
||||||
|
"taler",
|
||||||
|
"CURRENCY");
|
||||||
|
return GNUNET_SYSERR;
|
||||||
|
}
|
||||||
|
if (strlen (*currency) >= TALER_CURRENCY_LEN)
|
||||||
|
{
|
||||||
|
fprintf (stderr,
|
||||||
|
"Currency `%s' longer than the allowed limit of %u characters.",
|
||||||
|
*currency,
|
||||||
|
(unsigned int) TALER_CURRENCY_LEN);
|
||||||
|
GNUNET_free (*currency);
|
||||||
|
*currency = NULL;
|
||||||
|
return GNUNET_SYSERR;
|
||||||
|
}
|
||||||
|
return GNUNET_OK;
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user