diff options
author | Christian Grothoff <christian@grothoff.org> | 2024-03-18 23:08:17 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2024-03-18 23:08:17 +0100 |
commit | 200bbfbefda8c67ec5196d7384b32e9fa33c4bb7 (patch) | |
tree | 65f6c5dc4213bf23e451a4ac7213f4fcd16ce1a3 /src/mhd/mhd_parsing.c | |
parent | 21648351b98856e02db146a5277552053291f226 (diff) | |
download | exchange-200bbfbefda8c67ec5196d7384b32e9fa33c4bb7.tar.xz |
add new TALER_MHD_parse_request_arg_snumber function to libtalermhd
Diffstat (limited to 'src/mhd/mhd_parsing.c')
-rw-r--r-- | src/mhd/mhd_parsing.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/mhd/mhd_parsing.c b/src/mhd/mhd_parsing.c index 1e8258f55..2c3312cf2 100644 --- a/src/mhd/mhd_parsing.c +++ b/src/mhd/mhd_parsing.c @@ -246,6 +246,42 @@ TALER_MHD_parse_request_arg_number (struct MHD_Connection *connection, enum GNUNET_GenericReturnValue +TALER_MHD_parse_request_arg_snumber (struct MHD_Connection *connection, + const char *name, + int64_t *val) +{ + const char *ts; + char dummy; + long long num; + + ts = MHD_lookup_connection_value (connection, + MHD_GET_ARGUMENT_KIND, + name); + if (NULL == ts) + return GNUNET_OK; + if (1 != + sscanf (ts, + "%lld%c", + &num, + &dummy)) + { + MHD_RESULT mret; + + GNUNET_break_op (0); + mret = TALER_MHD_reply_with_error (connection, + MHD_HTTP_BAD_REQUEST, + TALER_EC_GENERIC_PARAMETER_MALFORMED, + name); + return (MHD_YES == mret) + ? GNUNET_NO + : GNUNET_SYSERR; + } + *val = (int64_t) num; + return GNUNET_OK; +} + + +enum GNUNET_GenericReturnValue TALER_MHD_parse_request_arg_amount (struct MHD_Connection *connection, const char *name, struct TALER_Amount *val) |