aboutsummaryrefslogtreecommitdiff
path: root/src/mhd
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2024-03-03 11:45:01 +0100
committerChristian Grothoff <christian@grothoff.org>2024-03-03 11:45:01 +0100
commit75067210fead522fc72327bfa3ac5504d7eed28c (patch)
treebeed191e9e6561375672328c874b190dc5d283ce /src/mhd
parent295be9df8e96d55df0d58940dcfeee3f3a93840d (diff)
downloadexchange-75067210fead522fc72327bfa3ac5504d7eed28c.tar.xz
add helper to parse amounts given as query parameters
Diffstat (limited to 'src/mhd')
-rw-r--r--src/mhd/Makefile.am4
-rw-r--r--src/mhd/mhd_parsing.c33
2 files changed, 34 insertions, 3 deletions
diff --git a/src/mhd/Makefile.am b/src/mhd/Makefile.am
index f7f052d51..1e3c49397 100644
--- a/src/mhd/Makefile.am
+++ b/src/mhd/Makefile.am
@@ -16,12 +16,12 @@ libtalermhd_la_SOURCES = \
mhd_responses.c \
mhd_run.c
libtalermhd_la_LDFLAGS = \
- -version-info 0:0:0 \
+ -version-info 1:0:1 \
-no-undefined
libtalermhd_la_LIBADD = \
- -lgnunetjson \
$(top_builddir)/src/json/libtalerjson.la \
$(top_builddir)/src/util/libtalerutil.la \
+ -lgnunetjson \
-lgnunetutil \
-lmicrohttpd \
-ljansson \
diff --git a/src/mhd/mhd_parsing.c b/src/mhd/mhd_parsing.c
index 381b064fa..1e8258f55 100644
--- a/src/mhd/mhd_parsing.c
+++ b/src/mhd/mhd_parsing.c
@@ -1,6 +1,6 @@
/*
This file is part of TALER
- Copyright (C) 2014--2020 Taler Systems SA
+ Copyright (C) 2014--2024 Taler Systems SA
TALER is free software; you can redistribute it and/or modify it under the
terms of the GNU Affero General Public License as published by the Free Software
@@ -246,6 +246,37 @@ TALER_MHD_parse_request_arg_number (struct MHD_Connection *connection,
enum GNUNET_GenericReturnValue
+TALER_MHD_parse_request_arg_amount (struct MHD_Connection *connection,
+ const char *name,
+ struct TALER_Amount *val)
+{
+ const char *ts;
+
+ ts = MHD_lookup_connection_value (connection,
+ MHD_GET_ARGUMENT_KIND,
+ name);
+ if (NULL == ts)
+ return GNUNET_OK;
+ if (GNUNET_OK !=
+ TALER_string_to_amount (ts,
+ val))
+ {
+ 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;
+ }
+ return GNUNET_OK;
+}
+
+
+enum GNUNET_GenericReturnValue
TALER_MHD_parse_json_data (struct MHD_Connection *connection,
const json_t *root,
struct GNUNET_JSON_Specification *spec)