diff options
Diffstat (limited to 'src/util')
| -rw-r--r-- | src/util/Makefile.am | 14 | ||||
| -rw-r--r-- | src/util/test_payto.c | 35 | ||||
| -rw-r--r-- | src/util/test_url.c | 3 | ||||
| -rw-r--r-- | src/util/util.c | 58 | 
4 files changed, 104 insertions, 6 deletions
| diff --git a/src/util/Makefile.am b/src/util/Makefile.am index 89b31ebb..35abe4a1 100644 --- a/src/util/Makefile.am +++ b/src/util/Makefile.am @@ -56,16 +56,16 @@ libtalerutil_la_LDFLAGS = \    -version-info 0:0:0 \    -export-dynamic -no-undefined -TESTS = \ - test_amount \ - test_crypto \ - test_url  check_PROGRAMS = \   test_amount \   test_crypto \ + test_payto \   test_url +TESTS = \ + $(check_PROGRAMS) +  test_amount_SOURCES = \    test_amount.c @@ -79,6 +79,12 @@ test_crypto_LDADD = \    -lgnunetutil \    libtalerutil.la +test_payto_SOURCES = \ +  test_payto.c +test_payto_LDADD = \ +  -lgnunetutil \ +  libtalerutil.la +  test_url_SOURCES = \    test_url.c  test_url_LDADD = \ diff --git a/src/util/test_payto.c b/src/util/test_payto.c new file mode 100644 index 00000000..80bf652e --- /dev/null +++ b/src/util/test_payto.c @@ -0,0 +1,35 @@ +/* +  This file is part of TALER +  (C) 2020 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 util/test_payto.c + * @brief Tests for payto helpers + * @author Christian Grothoff + */ +#include "platform.h" +#include "taler_util.h" + + +int +main (int argc, +      const char *const argv[]) +{ + + +  return 0; +} + + +/* end of test_payto.c */ diff --git a/src/util/test_url.c b/src/util/test_url.c index 5fc47137..4be1e730 100644 --- a/src/util/test_url.c +++ b/src/util/test_url.c @@ -1,6 +1,6 @@  /*    This file is part of TALER -  (C) 2015 GNUnet e.V. +  (C) 2015-2020 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 @@ -45,7 +45,6 @@ int  main (int argc,        const char *const argv[])  { -    cf (TALER_urlencode (""), "");    cf (TALER_urlencode ("abc"), "abc");    cf (TALER_urlencode ("~~"), "~~"); diff --git a/src/util/util.c b/src/util/util.c index 50ac5c1a..62f733a1 100644 --- a/src/util/util.c +++ b/src/util/util.c @@ -805,4 +805,62 @@ TALER_payto_xtalerbank_make (const char *bank_url,  } +/** + * 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; + +  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, +                (unsigned char) '/'); +  if (NULL == end) +    end = &start[strlen (start)]; +  return GNUNET_strndup (start, +                         end - start); +} + + +/** + * 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_account_url_from_payto (const char *payto) +{ +  const char *start; +  const char *end; + +  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, +                (unsigned char) '?'); +  if (NULL == end) +    end = &start[strlen (start)]; +  return GNUNET_strndup (start, +                         end - start); +} + +  /* end of util.c */ | 
