[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-exchange] branch master updated: add new TALER_MHD_parse_request_
From: |
gnunet |
Subject: |
[taler-exchange] branch master updated: add new TALER_MHD_parse_request_arg_snumber function to libtalermhd |
Date: |
Mon, 18 Mar 2024 23:08:20 +0100 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a commit to branch master
in repository exchange.
The following commit(s) were added to refs/heads/master by this push:
new 200bbfbe add new TALER_MHD_parse_request_arg_snumber function to
libtalermhd
200bbfbe is described below
commit 200bbfbefda8c67ec5196d7384b32e9fa33c4bb7
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Mon Mar 18 23:08:17 2024 +0100
add new TALER_MHD_parse_request_arg_snumber function to libtalermhd
---
src/include/taler_mhd_lib.h | 44 ++++++++++++++++++++++++++++++++++++++++++++
src/mhd/Makefile.am | 2 +-
src/mhd/mhd_parsing.c | 36 ++++++++++++++++++++++++++++++++++++
3 files changed, 81 insertions(+), 1 deletion(-)
diff --git a/src/include/taler_mhd_lib.h b/src/include/taler_mhd_lib.h
index c16772bf..d93bc1e1 100644
--- a/src/include/taler_mhd_lib.h
+++ b/src/include/taler_mhd_lib.h
@@ -521,6 +521,50 @@ TALER_MHD_parse_request_arg_number (struct MHD_Connection
*connection,
} while (0)
+/**
+ * Extract optional signed numeric limit argument from request.
+ *
+ * @param connection the MHD connection
+ * @param name name of the query parameter
+ * @param[out] val set to the signed value, unchanged if the
+ * option was not given
+ * @return #GNUNET_OK on success,
+ * #GNUNET_NO if an error was returned on @a connection (caller should
return #MHD_YES) and
+ * #GNUNET_SYSERR if we failed to return an error (caller should return
#MHD_NO)
+ */
+enum GNUNET_GenericReturnValue
+TALER_MHD_parse_request_arg_snumber (struct MHD_Connection *connection,
+ const char *name,
+ int64_t *val);
+
+
+/**
+ * Extract optional numeric argument from request.
+ * Macro that *returns* #MHD_YES/#MHD_NO if the
+ * requested argument existed but failed to parse.
+ *
+ * @param connection the MHD connection
+ * @param name name of the argument to parse
+ * @param[out] val set to the given numeric value,
+ * unchanged if value was not specified
+ */
+#define TALER_MHD_parse_request_snumber(connection,name,val) \
+ do { \
+ switch (TALER_MHD_parse_request_arg_snumber (connection, \
+ name, \
+ val)) \
+ { \
+ case GNUNET_SYSERR: \
+ GNUNET_break (0); \
+ return MHD_NO; \
+ case GNUNET_NO: \
+ GNUNET_break_op (0); \
+ case GNUNET_OK: \
+ break; \
+ } \
+ } while (0)
+
+
/**
* Extract optional amount argument from request.
*
diff --git a/src/mhd/Makefile.am b/src/mhd/Makefile.am
index 1e3c4939..d36bba42 100644
--- a/src/mhd/Makefile.am
+++ b/src/mhd/Makefile.am
@@ -16,7 +16,7 @@ libtalermhd_la_SOURCES = \
mhd_responses.c \
mhd_run.c
libtalermhd_la_LDFLAGS = \
- -version-info 1:0:1 \
+ -version-info 2:0:2 \
-no-undefined
libtalermhd_la_LIBADD = \
$(top_builddir)/src/json/libtalerjson.la \
diff --git a/src/mhd/mhd_parsing.c b/src/mhd/mhd_parsing.c
index 1e8258f5..2c3312cf 100644
--- a/src/mhd/mhd_parsing.c
+++ b/src/mhd/mhd_parsing.c
@@ -245,6 +245,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,
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [taler-exchange] branch master updated: add new TALER_MHD_parse_request_arg_snumber function to libtalermhd,
gnunet <=