diff options
author | Christian Grothoff <christian@grothoff.org> | 2020-01-11 15:19:56 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2020-01-11 15:20:17 +0100 |
commit | 9443c10d7feb0d91323869dd08ec61ca781564f4 (patch) | |
tree | fd617ea56cc1d2ea370ce7e5467574a536b52d28 /src/wire/payto.c | |
parent | 554da10133eb491b352a106b98ebeaed797133bb (diff) | |
download | exchange-9443c10d7feb0d91323869dd08ec61ca781564f4.tar.xz |
major refactoring, eliminating wire-plugins and moving towards new bank API. main code compiles, testcases known to fail, code sure not to fully work yet
Diffstat (limited to 'src/wire/payto.c')
-rw-r--r-- | src/wire/payto.c | 104 |
1 files changed, 42 insertions, 62 deletions
diff --git a/src/wire/payto.c b/src/wire/payto.c index 741549772..0c3fce957 100644 --- a/src/wire/payto.c +++ b/src/wire/payto.c @@ -20,6 +20,7 @@ */ #include "platform.h" #include "taler_util.h" +#include "taler_bank_service.h" #include "taler_wire_lib.h" /** @@ -43,8 +44,8 @@ TALER_WIRE_account_free (struct TALER_Account *acc) case TALER_PAC_X_TALER_BANK: GNUNET_free (acc->details.x_taler_bank.hostname); acc->details.x_taler_bank.hostname = NULL; - GNUNET_free (acc->details.x_taler_bank.bank_base_url); - acc->details.x_taler_bank.bank_base_url = NULL; + GNUNET_free (acc->details.x_taler_bank.account_base_url); + acc->details.x_taler_bank.account_base_url = NULL; break; case TALER_PAC_IBAN: GNUNET_free (acc->details.iban.number); @@ -410,7 +411,8 @@ parse_payto_x_taler_bank (const char *account_url, const char *hostname; const char *account; const char *q; - unsigned long long no; + unsigned int port; + char *p; #define PREFIX "payto://x-taler-bank/" if (0 != strncasecmp (account_url, @@ -422,74 +424,52 @@ parse_payto_x_taler_bank (const char *account_url, (unsigned char) '/'))) return TALER_EC_PAYTO_MALFORMED; account++; - if (NULL != (q = strchr (account, - (unsigned char) '?'))) + if (NULL == r_account) + return TALER_EC_NONE; + q = strchr (account, + (unsigned char) '?'); + if (0 == q) + q = account + strlen (account); + r_account->details.x_taler_bank.hostname + = GNUNET_strndup (hostname, + account - hostname); + port = 443; /* if non given, equals 443. */ + if (NULL != (p = strchr (r_account->details.x_taler_bank.hostname, + (unsigned char) ':'))) { - char *s; - - s = GNUNET_strndup (account, - q - account); - if (1 != sscanf (s, - "%llu", - &no)) + p++; + if (1 != sscanf (p, + "%u", + &port)) { - GNUNET_free (s); + GNUNET_break (0); + TALER_LOG_ERROR ("Malformed host from payto:// URI\n"); + GNUNET_free (r_account->details.x_taler_bank.hostname); + r_account->details.x_taler_bank.hostname = NULL; return TALER_EC_PAYTO_MALFORMED; } - GNUNET_free (s); } - else if (1 != sscanf (account, - "%llu", - &no)) + if (443 != port) { - return TALER_EC_PAYTO_MALFORMED; + GNUNET_assert + (GNUNET_SYSERR != GNUNET_asprintf + (&r_account->details.x_taler_bank.account_base_url, + "http://%s/%.*s", + r_account->details.x_taler_bank.hostname, + (int) (q - account), + account)); } - if (no > MAX_ACCOUNT_NO) - return TALER_EC_PAYTO_MALFORMED; - - if (NULL != r_account) + else { - long long unsigned port; - char *p; - - r_account->details.x_taler_bank.hostname - = GNUNET_strndup (hostname, - account - hostname); - r_account->details.x_taler_bank.no = no; - port = 443; /* if non given, equals 443. */ - if (NULL != (p = strchr (r_account->details.x_taler_bank.hostname, - (unsigned char) ':'))) - { - p++; - if (1 != sscanf (p, - "%llu", - &port)) - { - GNUNET_break (0); - TALER_LOG_ERROR ("Malformed host from payto:// URI\n"); - GNUNET_free (r_account->details.x_taler_bank.hostname); - r_account->details.x_taler_bank.hostname = NULL; - return TALER_EC_PAYTO_MALFORMED; - } - } - if (443 != port) - { - GNUNET_assert - (GNUNET_SYSERR != GNUNET_asprintf - (&r_account->details.x_taler_bank.bank_base_url, - "http://%s", - r_account->details.x_taler_bank.hostname)); - } - else - { - GNUNET_assert - (GNUNET_SYSERR != GNUNET_asprintf - (&r_account->details.x_taler_bank.bank_base_url, - "https://%s", - r_account->details.x_taler_bank.hostname)); - } - r_account->type = TALER_PAC_X_TALER_BANK; + GNUNET_assert + (GNUNET_SYSERR != GNUNET_asprintf + (&r_account->details.x_taler_bank.account_base_url, + "https://%s/%.*s", + r_account->details.x_taler_bank.hostname, + (int) (q - account), + account)); } + r_account->type = TALER_PAC_X_TALER_BANK; return TALER_EC_NONE; } |