aboutsummaryrefslogtreecommitdiff
path: root/src/util/config.c
diff options
context:
space:
mode:
authorChristian Grothoff <grothoff@gnunet.org>2023-10-08 10:51:02 +0200
committerChristian Grothoff <grothoff@gnunet.org>2023-10-08 10:51:02 +0200
commit2bccd24ecf7286ff35d464544358ffa414d39619 (patch)
tree960863b33412470dc863143f11c37470484d2af9 /src/util/config.c
parent4c4e5f9cb4faf71c304060b0622a7b43b6280fb2 (diff)
downloadexchange-2bccd24ecf7286ff35d464544358ffa414d39619.tar.xz
currency DD51 JSON generation
Diffstat (limited to 'src/util/config.c')
-rw-r--r--src/util/config.c47
1 files changed, 42 insertions, 5 deletions
diff --git a/src/util/config.c b/src/util/config.c
index 125ea7b1b..9e1156240 100644
--- a/src/util/config.c
+++ b/src/util/config.c
@@ -21,7 +21,7 @@
*/
#include "platform.h"
#include "taler_util.h"
-
+#include <gnunet/gnunet_json_lib.h>
enum GNUNET_GenericReturnValue
TALER_config_get_amount (const struct GNUNET_CONFIGURATION_Handle *cfg,
@@ -241,12 +241,12 @@ parse_currencies_cb (void *cls,
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_string (cpc->cfg,
section,
- "NAME",
+ "CODE",
&str))
{
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
section,
- "NAME");
+ "CODE");
cpc->failure = true;
return;
}
@@ -254,8 +254,8 @@ parse_currencies_cb (void *cls,
{
GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR,
section,
- "NAME",
- "Name given is too long");
+ "CODE",
+ "Currency code name given is too long");
cpc->failure = true;
GNUNET_free (str);
return;
@@ -279,6 +279,20 @@ parse_currencies_cb (void *cls,
cspec->decimal_separator = str;
if (GNUNET_OK !=
+ GNUNET_CONFIGURATION_get_value_string (cpc->cfg,
+ section,
+ "NAME",
+ &str))
+ {
+ GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
+ section,
+ "NAME");
+ cpc->failure = true;
+ return;
+ }
+ cspec->name = str;
+
+ if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_number (cpc->cfg,
section,
"FRACTIONAL_INPUT_DIGITS",
@@ -407,6 +421,28 @@ TALER_CONFIG_parse_currencies (const struct GNUNET_CONFIGURATION_Handle *cfg,
}
+json_t *
+TALER_CONFIG_currency_specs_to_json (const struct
+ TALER_CurrencySpecification *cspec)
+{
+ return GNUNET_JSON_PACK (
+ GNUNET_JSON_pack_string ("decimal_separator",
+ cspec->decimal_separator),
+ GNUNET_JSON_pack_string ("name",
+ cspec->name),
+ GNUNET_JSON_pack_uint64 ("num_fractional_input_digits",
+ cspec->num_fractional_input_digits),
+ GNUNET_JSON_pack_uint64 ("num_fractional_normal_digits",
+ cspec->num_fractional_normal_digits),
+ GNUNET_JSON_pack_uint64 ("num_fractional_trailing_zero_digits",
+ cspec->num_fractional_trailing_zero_digits),
+ GNUNET_JSON_pack_bool ("is_currency_name_leading",
+ cspec->is_currency_name_leading),
+ GNUNET_JSON_pack_object_incref ("alt_unit_names",
+ cspec->map_alt_unit_names));
+}
+
+
void
TALER_CONFIG_free_currencies (
unsigned int num_currencies,
@@ -417,6 +453,7 @@ TALER_CONFIG_free_currencies (
struct TALER_CurrencySpecification *cspec = &cspecs[i];
GNUNET_free (cspec->decimal_separator);
+ GNUNET_free (cspec->name);
json_decref (cspec->map_alt_unit_names);
}
GNUNET_array_grow (cspecs,