diff options
-rw-r--r-- | src/exchange/Makefile.am | 2 | ||||
-rw-r--r-- | src/exchange/taler-exchange-httpd.c | 10 | ||||
-rw-r--r-- | src/exchange/taler-exchange-httpd_aml-attributes-get.h | 2 | ||||
-rw-r--r-- | src/exchange/taler-exchange-httpd_aml-measures-get.c | 73 | ||||
-rw-r--r-- | src/exchange/taler-exchange-httpd_aml-measures-get.h | 45 | ||||
-rw-r--r-- | src/exchange/taler-exchange-httpd_aml-statistics-get.c | 103 | ||||
-rw-r--r-- | src/exchange/taler-exchange-httpd_aml-statistics-get.h | 45 | ||||
-rw-r--r-- | src/exchangedb/Makefile.am | 1 | ||||
-rw-r--r-- | src/exchangedb/pg_select_aml_statistics.c | 38 | ||||
-rw-r--r-- | src/exchangedb/pg_select_aml_statistics.h | 47 | ||||
-rw-r--r-- | src/exchangedb/plugin_exchangedb_postgres.c | 3 | ||||
-rw-r--r-- | src/include/taler_exchangedb_plugin.h | 21 | ||||
-rw-r--r-- | src/include/taler_mhd_lib.h | 42 | ||||
-rw-r--r-- | src/mhd/mhd_parsing.c | 81 |
14 files changed, 494 insertions, 19 deletions
diff --git a/src/exchange/Makefile.am b/src/exchange/Makefile.am index 851435642..1b10694f6 100644 --- a/src/exchange/Makefile.am +++ b/src/exchange/Makefile.am @@ -129,6 +129,8 @@ taler_exchange_httpd_SOURCES = \ taler-exchange-httpd_aml-attributes-get.c taler-exchange-httpd_aml-attributes-get.h \ taler-exchange-httpd_aml-decision.c taler-exchange-httpd_aml-decision.h \ taler-exchange-httpd_aml-decisions-get.c \ + taler-exchange-httpd_aml-statistics-get.c taler-exchange-httpd_aml-statistics-get.h \ + taler-exchange-httpd_aml-measures-get.c taler-exchange-httpd_aml-measures-get.h \ taler-exchange-httpd_auditors.c taler-exchange-httpd_auditors.h \ taler-exchange-httpd_batch-deposit.c taler-exchange-httpd_batch-deposit.h \ taler-exchange-httpd_batch-withdraw.c taler-exchange-httpd_batch-withdraw.h \ diff --git a/src/exchange/taler-exchange-httpd.c b/src/exchange/taler-exchange-httpd.c index d29d3d298..a167612b8 100644 --- a/src/exchange/taler-exchange-httpd.c +++ b/src/exchange/taler-exchange-httpd.c @@ -34,6 +34,8 @@ #include "taler-exchange-httpd_age-withdraw_reveal.h" #include "taler-exchange-httpd_aml-attributes-get.h" #include "taler-exchange-httpd_aml-decision.h" +#include "taler-exchange-httpd_aml-statistics-get.h" +#include "taler-exchange-httpd_aml-measures-get.h" #include "taler-exchange-httpd_auditors.h" #include "taler-exchange-httpd_batch-deposit.h" #include "taler-exchange-httpd_batch-withdraw.h" @@ -563,6 +565,14 @@ handle_get_aml (struct TEH_RequestContext *rc, .handler = &TEH_handler_aml_attributes_get }, { + .op = "kyc-statistics", + .handler = &TEH_handler_aml_kyc_statistics_get + }, + { + .op = "measures", + .handler = &TEH_handler_aml_measures_get + }, + { .op = NULL, .handler = NULL }, diff --git a/src/exchange/taler-exchange-httpd_aml-attributes-get.h b/src/exchange/taler-exchange-httpd_aml-attributes-get.h index a8e7c59d2..6fbfc1292 100644 --- a/src/exchange/taler-exchange-httpd_aml-attributes-get.h +++ b/src/exchange/taler-exchange-httpd_aml-attributes-get.h @@ -15,7 +15,7 @@ */ /** * @file taler-exchange-httpd_aml-attributes-get.h - * @brief Handle /aml/$OFFICER_PUB/decision requests + * @brief Handle /aml/$OFFICER_PUB/attributes/$H_PAYTO requests * @author Christian Grothoff */ #ifndef TALER_EXCHANGE_HTTPD_AML_ATTRIBUTES_GET_H diff --git a/src/exchange/taler-exchange-httpd_aml-measures-get.c b/src/exchange/taler-exchange-httpd_aml-measures-get.c new file mode 100644 index 000000000..aca4343f4 --- /dev/null +++ b/src/exchange/taler-exchange-httpd_aml-measures-get.c @@ -0,0 +1,73 @@ +/* + This file is part of TALER + Copyright (C) 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 + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> +*/ +/** + * @file taler-exchange-httpd_aml-measures-get.c + * @brief Return summary information about KYC measures + * @author Christian Grothoff + */ +#include "platform.h" +#include <gnunet/gnunet_util_lib.h> +#include <jansson.h> +#include <microhttpd.h> +#include <pthread.h> +#include "taler_json_lib.h" +#include "taler_mhd_lib.h" +#include "taler_signatures.h" +#include "taler-exchange-httpd.h" +#include "taler_exchangedb_plugin.h" +#include "taler-exchange-httpd_aml-measures-get.h" +#include "taler-exchange-httpd_metrics.h" + + +MHD_RESULT +TEH_handler_aml_measures_get ( + struct TEH_RequestContext *rc, + const struct TALER_AmlOfficerPublicKeyP *officer_pub, + const char *const args[]) +{ + static json_t *roots; + static json_t *programs; + static json_t *checks; + + if (NULL == roots) + { + // FIXME: initialize these properly! + roots = json_object (); + programs = json_object (); + checks = json_object (); + } + if (NULL != args[0]) + { + GNUNET_break_op (0); + return TALER_MHD_reply_with_error ( + rc->connection, + MHD_HTTP_NOT_FOUND, + TALER_EC_GENERIC_ENDPOINT_UNKNOWN, + rc->url); + } + return TALER_MHD_REPLY_JSON_PACK ( + rc->connection, + MHD_HTTP_OK, + GNUNET_JSON_pack_object_incref ("roots", + roots), + GNUNET_JSON_pack_object_incref ("programs", + programs), + GNUNET_JSON_pack_object_incref ("checks", + checks)); +} + + +/* end of taler-exchange-httpd_aml-measures_get.c */ diff --git a/src/exchange/taler-exchange-httpd_aml-measures-get.h b/src/exchange/taler-exchange-httpd_aml-measures-get.h new file mode 100644 index 000000000..6497ccdcf --- /dev/null +++ b/src/exchange/taler-exchange-httpd_aml-measures-get.h @@ -0,0 +1,45 @@ +/* + This file is part of TALER + Copyright (C) 2023 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 + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> +*/ +/** + * @file taler-exchange-httpd_aml-measures-get.h + * @brief Handle /aml/$OFFICER_PUB/measures requests + * @author Christian Grothoff + */ +#ifndef TALER_EXCHANGE_HTTPD_AML_MEASURES_GET_H +#define TALER_EXCHANGE_HTTPD_AML_MEASURES_GET_H + +#include <microhttpd.h> +#include "taler-exchange-httpd.h" + + +/** + * Handle a GET "/aml/$OFFICER_PUB/measures" request. Parses the request + * details, checks the signatures and if appropriately authorized returns + * the matching decisions. + * + * @param rc request context + * @param officer_pub public key of the AML officer who made the request + * @param args GET arguments (should be empty) + * @return MHD result code + */ +MHD_RESULT +TEH_handler_aml_measures_get ( + struct TEH_RequestContext *rc, + const struct TALER_AmlOfficerPublicKeyP *officer_pub, + const char *const args[]); + + +#endif diff --git a/src/exchange/taler-exchange-httpd_aml-statistics-get.c b/src/exchange/taler-exchange-httpd_aml-statistics-get.c new file mode 100644 index 000000000..ddf1e9697 --- /dev/null +++ b/src/exchange/taler-exchange-httpd_aml-statistics-get.c @@ -0,0 +1,103 @@ +/* + This file is part of TALER + Copyright (C) 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 + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> +*/ +/** + * @file taler-exchange-httpd_aml-statistics-get.c + * @brief Return summary information about KYC statistics + * @author Christian Grothoff + */ +#include "platform.h" +#include <gnunet/gnunet_util_lib.h> +#include <jansson.h> +#include <microhttpd.h> +#include <pthread.h> +#include "taler_json_lib.h" +#include "taler_mhd_lib.h" +#include "taler_signatures.h" +#include "taler-exchange-httpd.h" +#include "taler_exchangedb_plugin.h" +#include "taler-exchange-httpd_aml-statistics-get.h" +#include "taler-exchange-httpd_metrics.h" + + +MHD_RESULT +TEH_handler_aml_kyc_statistics_get ( + struct TEH_RequestContext *rc, + const struct TALER_AmlOfficerPublicKeyP *officer_pub, + const char *const args[]) +{ + struct GNUNET_TIME_Timestamp start_date; + struct GNUNET_TIME_Timestamp end_date; + const char *name = args[0]; + uint64_t cnt; + + if ( (NULL == args[0]) || + (NULL != args[1]) ) + { + GNUNET_break_op (0); + return TALER_MHD_reply_with_error ( + rc->connection, + MHD_HTTP_NOT_FOUND, + TALER_EC_GENERIC_ENDPOINT_UNKNOWN, + rc->url); + } + start_date = GNUNET_TIME_UNIT_ZERO_TS; + end_date = GNUNET_TIME_timestamp_get (); + + TALER_MHD_parse_request_timestamp (rc->connection, + "start_date", + &start_date); + TALER_MHD_parse_request_timestamp (rc->connection, + "end_date", + &end_date); + { + enum GNUNET_DB_QueryStatus qs; + + qs = TEH_plugin->select_aml_statistics ( + TEH_plugin->cls, + name, + start_date, + end_date, + &cnt); + switch (qs) + { + case GNUNET_DB_STATUS_HARD_ERROR: + case GNUNET_DB_STATUS_SOFT_ERROR: + GNUNET_break (0); + return TALER_MHD_reply_with_error ( + rc->connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_FETCH_FAILED, + "select_aml_statistics"); + case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: + return TALER_MHD_reply_static ( + rc->connection, + MHD_HTTP_NO_CONTENT, + NULL, + NULL, + 0); + case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT: + break; + } + return TALER_MHD_REPLY_JSON_PACK ( + rc->connection, + MHD_HTTP_OK, + GNUNET_JSON_pack_uint64 ("counter", + cnt)); + } +} + + +/* end of taler-exchange-httpd_aml-statistics_get.c */ diff --git a/src/exchange/taler-exchange-httpd_aml-statistics-get.h b/src/exchange/taler-exchange-httpd_aml-statistics-get.h new file mode 100644 index 000000000..bb1fac05e --- /dev/null +++ b/src/exchange/taler-exchange-httpd_aml-statistics-get.h @@ -0,0 +1,45 @@ +/* + This file is part of TALER + Copyright (C) 2023 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 + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> +*/ +/** + * @file taler-exchange-httpd_aml-statistics-get.h + * @brief Handle /aml/$OFFICER_PUB/kyc-statistics/$NAME requests + * @author Christian Grothoff + */ +#ifndef TALER_EXCHANGE_HTTPD_AML_STATISTICS_GET_H +#define TALER_EXCHANGE_HTTPD_AML_STATISTICS_GET_H + +#include <microhttpd.h> +#include "taler-exchange-httpd.h" + + +/** + * Handle a GET "/aml/$OFFICER_PUB/kyc-statistics/$NAME" request. Parses the request + * details, checks the signatures and if appropriately authorized returns + * the matching decisions. + * + * @param rc request context + * @param officer_pub public key of the AML officer who made the request + * @param args GET arguments (name of the statistic) + * @return MHD result code + */ +MHD_RESULT +TEH_handler_aml_kyc_statistics_get ( + struct TEH_RequestContext *rc, + const struct TALER_AmlOfficerPublicKeyP *officer_pub, + const char *const args[]); + + +#endif diff --git a/src/exchangedb/Makefile.am b/src/exchangedb/Makefile.am index cc73674a3..ff995508b 100644 --- a/src/exchangedb/Makefile.am +++ b/src/exchangedb/Makefile.am @@ -158,6 +158,7 @@ libtaler_plugin_exchangedb_postgres_la_SOURCES = \ pg_ensure_coin_known.h pg_ensure_coin_known.c \ pg_get_known_coin.h pg_get_known_coin.c \ pg_get_signature_for_known_coin.h pg_get_signature_for_known_coin.c \ + pg_select_aml_statistics.h pg_select_aml_statistics.c \ pg_get_coin_denomination.h pg_get_coin_denomination.c \ pg_select_aml_decisions.h pg_select_aml_decisions.c \ pg_have_deposit2.h pg_have_deposit2.c \ diff --git a/src/exchangedb/pg_select_aml_statistics.c b/src/exchangedb/pg_select_aml_statistics.c new file mode 100644 index 000000000..b12324358 --- /dev/null +++ b/src/exchangedb/pg_select_aml_statistics.c @@ -0,0 +1,38 @@ +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ +/** + * @file exchangedb/pg_select_aml_statistics.c + * @brief Implementation of the select_aml_statistics function for Postgres + * @author Christian Grothoff + */ +#include "platform.h" +#include "taler_error_codes.h" +#include "taler_dbevents.h" +#include "taler_pq_lib.h" +#include "pg_select_aml_statistics.h" +#include "pg_helper.h" + + +enum GNUNET_DB_QueryStatus +TEH_PG_select_aml_statistics ( + void *cls, + const char *name, + struct GNUNET_TIME_Timestamp start_date, + struct GNUNET_TIME_Timestamp end_date, + uint64_t *cnt) +{ + // FIXME! +} diff --git a/src/exchangedb/pg_select_aml_statistics.h b/src/exchangedb/pg_select_aml_statistics.h new file mode 100644 index 000000000..24ee56685 --- /dev/null +++ b/src/exchangedb/pg_select_aml_statistics.h @@ -0,0 +1,47 @@ +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ +/** + * @file exchangedb/pg_select_aml_statistics.h + * @brief implementation of the select_aml_statistics function for Postgres + * @author Christian Grothoff + */ +#ifndef PG_SELECT_AML_STATISTICS_H +#define PG_SELECT_AML_STATISTICS_H + +#include "taler_util.h" +#include "taler_json_lib.h" +#include "taler_exchangedb_plugin.h" + +/** + * Obtain the AML statistics for a given key and + * timeframe. + * + * @param cls closure + * @param name name of the statistic + * @param start_date start of time range + * @param end_date end of time range + * @param[out] cnt number of events in this time range + * @return database transaction status, 0 if no threshold was set + */ +enum GNUNET_DB_QueryStatus +TEH_PG_select_aml_statistics ( + void *cls, + const char *name, + struct GNUNET_TIME_Timestamp start_date, + struct GNUNET_TIME_Timestamp end_date, + uint64_t *cnt); + +#endif diff --git a/src/exchangedb/plugin_exchangedb_postgres.c b/src/exchangedb/plugin_exchangedb_postgres.c index fe4dbd27b..e65f2ef3f 100644 --- a/src/exchangedb/plugin_exchangedb_postgres.c +++ b/src/exchangedb/plugin_exchangedb_postgres.c @@ -67,6 +67,7 @@ #include "pg_insert_purse_request.h" #include "pg_iterate_active_signkeys.h" #include "pg_preflight.h" +#include "pg_select_aml_statistics.h" #include "pg_commit.h" #include "pg_drop_tables.h" #include "pg_get_kyc_rules.h" @@ -733,6 +734,8 @@ libtaler_plugin_exchangedb_postgres_init (void *cls) = &TEH_PG_insert_signkey_revocation; plugin->select_aml_attributes = &TEH_PG_select_aml_attributes; + plugin->select_aml_statistics + = &TEH_PG_select_aml_statistics; plugin->lookup_signkey_revocation = &TEH_PG_lookup_signkey_revocation; plugin->lookup_denomination_key diff --git a/src/include/taler_exchangedb_plugin.h b/src/include/taler_exchangedb_plugin.h index 642958b13..4f0ddf247 100644 --- a/src/include/taler_exchangedb_plugin.h +++ b/src/include/taler_exchangedb_plugin.h @@ -7149,6 +7149,27 @@ struct TALER_EXCHANGEDB_Plugin struct TALER_Amount *threshold); #endif + + /** + * Obtain the AML statistics for a given key and + * timeframe. + * + * @param cls closure + * @param name name of the statistic + * @param start_date start of time range + * @param end_date end of time range + * @param[out] cnt number of events in this time range + * @return database transaction status, 0 if no threshold was set + */ + enum GNUNET_DB_QueryStatus + (*select_aml_statistics)( + void *cls, + const char *name, + struct GNUNET_TIME_Timestamp start_date, + struct GNUNET_TIME_Timestamp end_date, + uint64_t *cnt); + + /** * Trigger AML process, an account has crossed the threshold. Inserts or * updates the AML status. diff --git a/src/include/taler_mhd_lib.h b/src/include/taler_mhd_lib.h index eaa6015c8..87a9beafd 100644 --- a/src/include/taler_mhd_lib.h +++ b/src/include/taler_mhd_lib.h @@ -478,6 +478,48 @@ TALER_MHD_parse_request_arg_timeout (struct MHD_Connection *connection, /** + * Extract optional timestamp argument from request. + * + * @param connection the MHD connection + * @param fname name of the argument to parse + * @param[out] ts set to #GNUNET_TIME_UNIT_ZERO_TS if there was no timestamp + * @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_timestamp (struct MHD_Connection *connection, + const char *fname, + struct GNUNET_TIME_Timestamp *ts); + + +/** + * Extract optional timestamp argument from request. + * Macro that *returns* #MHD_YES/#MHD_NO if the timestamp + * argument existed but failed to parse. + * + * @param connection the MHD connection + * @param fname name of the argument + * @param[out] ts set to #GNUNET_TIME_UNIT_ZERO_TS if there was no timestamp + */ +#define TALER_MHD_parse_request_timestamp(connection,fname,ts) \ + do { \ + switch (TALER_MHD_parse_request_arg_timestamp (connection, \ + fname, \ + ts)) \ + { \ + case GNUNET_SYSERR: \ + GNUNET_break (0); \ + return MHD_NO; \ + case GNUNET_NO: \ + GNUNET_break_op (0); \ + case GNUNET_OK: \ + break; \ + } \ + } while (0) + + +/** * Extract optional "yes/no/all" argument from request. * Macro that *returns* #MHD_YES/#MHD_NO if the * argument existed but failed to parse. diff --git a/src/mhd/mhd_parsing.c b/src/mhd/mhd_parsing.c index 771319bd5..1f50edd92 100644 --- a/src/mhd/mhd_parsing.c +++ b/src/mhd/mhd_parsing.c @@ -104,12 +104,13 @@ TALER_MHD_parse_post_cleanup_callback (void *con_cls) * #GNUNET_SYSERR on internal error (error response could not be sent) */ static enum GNUNET_GenericReturnValue -parse_request_data (struct MHD_Connection *connection, - const char *param_name, - enum MHD_ValueKind kind, - void *out_data, - size_t out_size, - bool *present) +parse_request_data ( + struct MHD_Connection *connection, + const char *param_name, + enum MHD_ValueKind kind, + void *out_data, + size_t out_size, + bool *present) { const char *str; @@ -138,11 +139,12 @@ parse_request_data (struct MHD_Connection *connection, enum GNUNET_GenericReturnValue -TALER_MHD_parse_request_arg_data (struct MHD_Connection *connection, - const char *param_name, - void *out_data, - size_t out_size, - bool *present) +TALER_MHD_parse_request_arg_data ( + struct MHD_Connection *connection, + const char *param_name, + void *out_data, + size_t out_size, + bool *present) { return parse_request_data (connection, param_name, @@ -154,11 +156,12 @@ TALER_MHD_parse_request_arg_data (struct MHD_Connection *connection, enum GNUNET_GenericReturnValue -TALER_MHD_parse_request_header_data (struct MHD_Connection *connection, - const char *header_name, - void *out_data, - size_t out_size, - bool *present) +TALER_MHD_parse_request_header_data ( + struct MHD_Connection *connection, + const char *header_name, + void *out_data, + size_t out_size, + bool *present) { return parse_request_data (connection, header_name, @@ -170,8 +173,9 @@ TALER_MHD_parse_request_header_data (struct MHD_Connection *connection, enum GNUNET_GenericReturnValue -TALER_MHD_parse_request_arg_timeout (struct MHD_Connection *connection, - struct GNUNET_TIME_Absolute *expiration) +TALER_MHD_parse_request_arg_timeout ( + struct MHD_Connection *connection, + struct GNUNET_TIME_Absolute *expiration) { const char *ts; char dummy; @@ -210,6 +214,47 @@ TALER_MHD_parse_request_arg_timeout (struct MHD_Connection *connection, enum GNUNET_GenericReturnValue +TALER_MHD_parse_request_arg_timestamp ( + struct MHD_Connection *connection, + const char *fname, + struct GNUNET_TIME_Timestamp *ts) +{ + const char *s; + char dummy; + unsigned long long t; + + s = MHD_lookup_connection_value (connection, + MHD_GET_ARGUMENT_KIND, + fname); + if (NULL == s) + { + *ts = GNUNET_TIME_UNIT_ZERO_TS; + return GNUNET_OK; + } + if (1 != + sscanf (s, + "%llu%c", + &t, + &dummy)) + { + MHD_RESULT mret; + + GNUNET_break_op (0); + mret = TALER_MHD_reply_with_error ( + connection, + MHD_HTTP_BAD_REQUEST, + TALER_EC_GENERIC_PARAMETER_MALFORMED, + fname); + return (MHD_YES == mret) + ? GNUNET_NO + : GNUNET_SYSERR; + } + *ts = GNUNET_TIME_timestamp_from_s (t); + return GNUNET_OK; +} + + +enum GNUNET_GenericReturnValue TALER_MHD_parse_request_arg_number (struct MHD_Connection *connection, const char *name, uint64_t *off) |