diff options
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/test_payto.c | 35 | ||||
-rw-r--r-- | src/util/util.c | 149 |
2 files changed, 0 insertions, 184 deletions
diff --git a/src/util/test_payto.c b/src/util/test_payto.c index 5807be20b..b7d73f80a 100644 --- a/src/util/test_payto.c +++ b/src/util/test_payto.c @@ -42,41 +42,6 @@ main (int argc, GNUNET_log_setup ("test-payto", "WARNING", NULL); - r = TALER_payto_xtalerbank_make ("https://localhost/", - "account"); - CHECK ("payto://x-taler-bank/localhost/account", - r); - r = TALER_payto_xtalerbank_make ("https://localhost", - "account"); - CHECK ("payto://x-taler-bank/localhost/account", - r); - r = TALER_payto_xtalerbank_make2 ("https://localhost/account"); - CHECK ("payto://x-taler-bank/localhost/account", - r); - r = TALER_payto_xtalerbank_make ("http://localhost:80/", - "account"); - CHECK ("payto://x-taler-bank/localhost:80/account", - r); - r = TALER_payto_xtalerbank_make ("http://localhost:80", - "account"); - CHECK ("payto://x-taler-bank/localhost:80/account", - r); - r = TALER_payto_xtalerbank_make ("http://localhost/", - "account"); - r = TALER_payto_xtalerbank_make2 ("http://localhost:80/account"); - CHECK ("payto://x-taler-bank/localhost:80/account", - r); - r = TALER_payto_xtalerbank_make2 ("http://localhost/account"); - CHECK ("payto://x-taler-bank/localhost:80/account", - r); - r = TALER_xtalerbank_base_url_from_payto ( - "payto://x-taler-bank/localhost/bob"); - CHECK ("https://localhost/", - r); - r = TALER_xtalerbank_base_url_from_payto ( - "payto://x-taler-bank/localhost:1080/bob"); - CHECK ("http://localhost:1080/", - r); r = TALER_xtalerbank_account_from_payto ( "payto://x-taler-bank/localhost:1080/alice"); CHECK ("alice", diff --git a/src/util/util.c b/src/util/util.c index 36c6f440c..c9316462b 100644 --- a/src/util/util.c +++ b/src/util/util.c @@ -571,155 +571,6 @@ TALER_payto_get_method (const char *payto_url) /** - * Create an x-taler-bank payto:// URL from a @a bank_url - * and an @a account_name. - * - * @param bank_url the bank URL - * @param account_name the account name - * @return payto:// URL - */ -char * -TALER_payto_xtalerbank_make (const char *bank_url, - const char *account_name) -{ - char *payto; - int plaintext; - const char *port; - size_t slen; - - if (0 == strncasecmp ("https://", - bank_url, - strlen ("https://"))) - { - bank_url += strlen ("https://"); - plaintext = GNUNET_NO; - } - else if (0 == strncasecmp ("http://", - bank_url, - strlen ("http://"))) - { - bank_url += strlen ("http://"); - plaintext = GNUNET_YES; - } - else - return NULL; - slen = strlen (bank_url); - port = memchr (bank_url, - ':', - slen); - if ( (0 < slen) && - ('/' == bank_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, - bank_url, - account_name); - return payto; -} - - -/** - * 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. - * - * @param payto the payto URL - * @return bank URL of the account, NULL if not x-taler-bak payto URL - */ -char * -TALER_xtalerbank_base_url_from_payto (const char *payto) -{ - const char *start; - const char *end; - char *ret; - int https; - const char *colon; - unsigned int port; - - if (0 != strncasecmp (payto, - "payto://x-taler-bank/", - strlen ("payto://x-taler-bank/"))) - return NULL; - start = &payto[strlen ("payto://x-taler-bank/")]; - end = strchr (start, - '/'); - if (NULL == end) - end = &start[strlen (start)]; - colon = strrchr (start, - ':'); - https = GNUNET_YES; - if ( (NULL != colon) && - (1 == sscanf (colon + 1, - "%u", - &port)) && - (443 != port) ) - https = GNUNET_NO; - GNUNET_asprintf (&ret, - "%s://%.*s/", - (https ? "https" : "http"), - (int) (end - start), - start); - return ret; -} - - -/** * Obtain the account name from a payto URL. * * @param payto an x-taler-bank payto URL |