From 0c4eca0d4858651d7415951c8a708c3380ccbb64 Mon Sep 17 00:00:00 2001 From: Jonathan Buchanan Date: Fri, 12 Jun 2020 15:16:40 -0400 Subject: moved yna to exchange --- src/include/taler_util.h | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'src/include/taler_util.h') diff --git a/src/include/taler_util.h b/src/include/taler_util.h index c7bf9c02..07b78a43 100644 --- a/src/include/taler_util.h +++ b/src/include/taler_util.h @@ -298,4 +298,41 @@ char * TALER_xtalerbank_account_from_payto (const char *payto); +/** + * Possible values for a binary filter. + */ +enum TALER_EXCHANGE_YesNoAll +{ + /** + * If condition is yes. + */ + TALER_EXCHANGE_YNA_YES = 1, + + /** + * If condition is no. + */ + TALER_EXCHANGE_YNA_NO = 2, + + /** + * Condition disabled. + */ + TALER_EXCHANGE_YNA_ALL = 3 +}; + + +/** + * Convert query argument to @a yna value. + * + * @param connection connection to take query argument from + * @param arg argument to try for + * @param default_val value to assign if the argument is not present + * @param[out] value to set + * @return true on success, false if the parameter was malformed + */ +bool +TALER_arg_to_yna (struct MHD_Connection *connection, + const char *arg, + enum TALER_EXCHANGE_YesNoAll default_val, + enum TALER_EXCHANGE_YesNoAll *yna); + #endif -- cgit v1.2.3 From a32a5ef25aa35c7c9228e5f8f9541aaef7f525c4 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sun, 14 Jun 2020 15:15:53 +0200 Subject: add TALER_yna_to_string() --- src/include/taler_util.h | 11 +++++++++++ src/util/yna.c | 22 ++++++++++++++++++++++ 2 files changed, 33 insertions(+) (limited to 'src/include/taler_util.h') diff --git a/src/include/taler_util.h b/src/include/taler_util.h index 07b78a43..22d7f7f2 100644 --- a/src/include/taler_util.h +++ b/src/include/taler_util.h @@ -335,4 +335,15 @@ TALER_arg_to_yna (struct MHD_Connection *connection, enum TALER_EXCHANGE_YesNoAll default_val, enum TALER_EXCHANGE_YesNoAll *yna); + +/** + * Convert YNA value to a string. + * + * @param yna value to convert + * @return string representation ("yes"/"no"/"all"). + */ +const char * +TALER_yna_to_string (enum TALER_EXCHANGE_YesNoAll yna); + + #endif diff --git a/src/util/yna.c b/src/util/yna.c index 6907df67..fa7cf934 100644 --- a/src/util/yna.c +++ b/src/util/yna.c @@ -64,3 +64,25 @@ TALER_arg_to_yna (struct MHD_Connection *connection, } return false; } + + +/** + * Convert YNA value to a string. + * + * @param yna value to convert + * @return string representation ("yes"/"no"/"all"). + */ +const char * +TALER_yna_to_string (enum TALER_EXCHANGE_YesNoAll yna) +{ + switch (yna) + { + case TALER_EXCHANGE_YNA_YES: + return "yes"; + case TALER_EXCHANGE_YNA_NO: + return "no"; + case TALER_EXCHANGE_YNA_ALL: + return "all"; + } + GNUNET_assert (0); +} -- cgit v1.2.3