From 4d6ef1da29e5c1bf4c2216d9fe0c14dcab0f04cd Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Mon, 13 Jan 2020 18:16:01 +0100 Subject: eliminate libtalerwire --- src/util/util.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'src/util/util.c') diff --git a/src/util/util.c b/src/util/util.c index fa65fc238..e312e345b 100644 --- a/src/util/util.c +++ b/src/util/util.c @@ -744,4 +744,36 @@ TALER_buffer_write_vfstr (struct TALER_Buffer *buf, } +/** + * Prefix of PAYTO URLs. + */ +#define PAYTO "payto://" + + +/** + * Obtain the payment method from a @a payto_url + * + * @param payto_url the URL to parse + * @return NULL on error (malformed @a payto_url) + */ +char * +TALER_payto_get_method (const char *payto_url) +{ + const char *start; + const char *end; + + if (0 != strncmp (payto_url, + PAYTO, + strlen (PAYTO))) + return NULL; + start = &payto_url[strlen (PAYTO)]; + end = strchr (start, + (unsigned char) '/'); + if (NULL == end) + return NULL; + return GNUNET_strndup (start, + end - start); +} + + /* end of util.c */ -- cgit v1.2.3