diff options
author | Christian Grothoff <christian@grothoff.org> | 2020-01-15 14:57:58 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2020-01-15 14:58:10 +0100 |
commit | b37fff0d5b08926169633ce8822de7ac616ae169 (patch) | |
tree | 88be0f24a260f2e7037cabd60227584a5c7f6749 /src/util/util.c | |
parent | d822035216d9ad33665a2f8274432918ca7d42be (diff) |
ftbfs
Diffstat (limited to 'src/util/util.c')
-rw-r--r-- | src/util/util.c | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/src/util/util.c b/src/util/util.c index 7f5e60e4d..761aa98dd 100644 --- a/src/util/util.c +++ b/src/util/util.c @@ -624,6 +624,60 @@ TALER_payto_xtalerbank_make (const char *bank_url, /** + * Create an x-taler-bank payto:// URL from an @a account_url. + * + * @param account_url the bank URL + * @param account_name the account name + * @return payto:// URL + */ +char * +TALER_payto_xtalerbank_make2 (const char *account_url) +{ + char *payto; + int plaintext; + const char *port; + size_t slen; + const char *account; + + if (0 == strncasecmp ("https://", + account_url, + strlen ("https://"))) + { + account_url += strlen ("https://"); + plaintext = GNUNET_NO; + } + else if (0 == strncasecmp ("http://", + account_url, + strlen ("http://"))) + { + account_url += strlen ("http://"); + plaintext = GNUNET_YES; + } + else + return NULL; + account = strchr (account_url, + '/'); + if (NULL == account) + return NULL; + slen = account - account_url; + port = memchr (account_url, + ':', + slen); + if ( (0 < slen) && + ('/' == account_url[slen - 1]) ) + slen--; + GNUNET_asprintf (&payto, + ( (NULL == port) && (GNUNET_YES == plaintext) ) + ? "payto://x-taler-bank/%.*s:80/%s" + : "payto://x-taler-bank/%.*s/%s", + (int) slen, + account_url, + account + 1); + return payto; +} + + +/** * Given an x-taler-bank payto:// URL, compute * the HTTP(S) base URL of the account. * |