commit 477f8d08a4678c473fd055c1d9991733eff1e03a
parent 5efb46bd255dd71b30d55b460987620837af1218
Author: Christian Grothoff <christian@grothoff.org>
Date: Mon, 16 Mar 2026 22:12:00 +0100
more APIs for #11253
Diffstat:
2 files changed, 40 insertions(+), 0 deletions(-)
diff --git a/src/include/taler/taler_amount_lib.h b/src/include/taler/taler_amount_lib.h
@@ -546,6 +546,21 @@ TALER_amount_set_test_above (const struct TALER_AmountSet *as,
const struct TALER_Amount *b);
+/**
+ * Find amount by @a currency in @a as. If @a as is not
+ * found, an amount of zero is returned in @a currency.
+ * This function is not reentrant, repeated calls may
+ * overwrite previously returned results.
+ *
+ * @param currency currency to search for
+ * @param as set to search
+ * @return NULL if @a currency is not a valid currency string
+ */
+const struct TALER_Amount *
+TALER_amount_set_find (const char *currency,
+ const struct TALER_AmountSet *as);
+
+
#if 0 /* keep Emacsens' auto-indent happy */
{
#endif
diff --git a/src/util/amount.c b/src/util/amount.c
@@ -946,4 +946,29 @@ TALER_amount_set_test_above (const struct TALER_AmountSet *as,
}
+const struct TALER_Amount *
+TALER_amount_set_find (const char *currency,
+ const struct TALER_AmountSet *as)
+{
+ static struct TALER_Amount z;
+
+ for (unsigned int i = 0; i<as->taa_size; i++)
+ {
+ const struct TALER_Amount *asi = &as->taa[i];
+
+ if (0 == strcasecmp (currency,
+ asi->currency))
+ return asi;
+ }
+ if (GNUNET_OK !=
+ TALER_amount_set_zero (currency,
+ &z))
+ {
+ GNUNET_break (0);
+ return NULL;
+ }
+ return &z;
+}
+
+
/* end of amount.c */