exchange

Base system with REST service to issue digital coins, run by the payment service provider
Log | Files | Refs | Submodules | README | LICENSE

commit f3329b20d1b6d26f4e7b150c9a08fed419eff892
parent eab454d8d278f497eaaed03bdd41dac0335a35c4
Author: Christian Grothoff <christian@grothoff.org>
Date:   Wed,  5 Aug 2026 00:26:08 +0200

libtalerjson: add TALER_JSON_spec_web_url_copy

Diffstat:
Msrc/include/taler/taler_json_lib.h | 13+++++++++++++
Msrc/json/json_helper.c | 47+++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 60 insertions(+), 0 deletions(-)

diff --git a/src/include/taler/taler_json_lib.h b/src/include/taler/taler_json_lib.h @@ -632,6 +632,19 @@ TALER_JSON_spec_web_url (const char *field, /** + * Generate line in parser specification for + * HTTP/HTTPS URLs. Creates a copy of the original string. + * + * @param field name of the field + * @param[out] url web URL to initialize + * @return corresponding field spec + */ +struct GNUNET_JSON_Specification +TALER_JSON_spec_web_url_copy (const char *field, + char **url); + + +/** * Generate line in parser specification for slugs (URL-safe identifiers). * * @param field name of the field diff --git a/src/json/json_helper.c b/src/json/json_helper.c @@ -1577,6 +1577,53 @@ TALER_JSON_spec_web_url (const char *field, /** + * Parse given JSON object to web URL, and make a copy. + * + * @param cls closure, NULL + * @param root the json object representing data + * @param[out] spec where to write the data + * @return #GNUNET_OK upon successful parsing; #GNUNET_SYSERR upon error + */ +static enum GNUNET_GenericReturnValue +parse_web_url_copy (void *cls, + json_t *root, + struct GNUNET_JSON_Specification *spec) +{ + const char *str; + + (void) cls; + str = json_string_value (root); + if (NULL == str) + { + GNUNET_break_op (0); + return GNUNET_SYSERR; + } + if (! TALER_is_web_url (str)) + { + GNUNET_break_op (0); + return GNUNET_SYSERR; + } + *(char **) spec->ptr = GNUNET_strdup (str); + return GNUNET_OK; +} + + +struct GNUNET_JSON_Specification +TALER_JSON_spec_web_url_copy (const char *field, + char **url) +{ + struct GNUNET_JSON_Specification ret = { + .parser = &parse_web_url_copy, + .field = field, + .ptr = url + }; + + *url = NULL; + return ret; +} + + +/** * Parse given JSON object to slug. * * @param cls closure, NULL