Payto parsing.
Moving the extracted bank base URL into proper structure.
This commit is contained in:
parent
5d1bb08a74
commit
465c666174
@ -202,6 +202,11 @@ struct Account
|
|||||||
* Bank account number.
|
* Bank account number.
|
||||||
*/
|
*/
|
||||||
unsigned long long no;
|
unsigned long long no;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Base URL of the bank hosting the account above.
|
||||||
|
*/
|
||||||
|
char *bank_base_url;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -257,11 +262,46 @@ parse_payto (const char *account_url,
|
|||||||
}
|
}
|
||||||
if (no > MAX_ACCOUNT_NO)
|
if (no > MAX_ACCOUNT_NO)
|
||||||
return TALER_EC_PAYTO_MALFORMED;
|
return TALER_EC_PAYTO_MALFORMED;
|
||||||
|
|
||||||
if (NULL != r_account)
|
if (NULL != r_account)
|
||||||
{
|
{
|
||||||
|
long long unsigned port;
|
||||||
|
char *p;
|
||||||
|
|
||||||
r_account->hostname = GNUNET_strndup (hostname,
|
r_account->hostname = GNUNET_strndup (hostname,
|
||||||
account - hostname);
|
account - hostname);
|
||||||
r_account->no = no;
|
r_account->no = no;
|
||||||
|
port = 443; /* if non given, equals 443. */
|
||||||
|
if (NULL != (p = strchr (r_account->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->hostname);
|
||||||
|
return TALER_EC_PAYTO_MALFORMED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (443 != port)
|
||||||
|
{
|
||||||
|
GNUNET_assert
|
||||||
|
(GNUNET_SYSERR != GNUNET_asprintf
|
||||||
|
(&r_account->bank_base_url,
|
||||||
|
"http://%s",
|
||||||
|
r_account->hostname));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
GNUNET_assert
|
||||||
|
(GNUNET_SYSERR != GNUNET_asprintf
|
||||||
|
(&r_account->bank_base_url,
|
||||||
|
"https://%s",
|
||||||
|
r_account->hostname));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return TALER_EC_NONE;
|
return TALER_EC_NONE;
|
||||||
}
|
}
|
||||||
@ -978,9 +1018,6 @@ taler_bank_get_history (void *cls,
|
|||||||
const uint64_t *start_off_b64;
|
const uint64_t *start_off_b64;
|
||||||
uint64_t start_row;
|
uint64_t start_row;
|
||||||
struct Account account;
|
struct Account account;
|
||||||
char *bank_base_url;
|
|
||||||
char *p;
|
|
||||||
long long unsigned port;
|
|
||||||
|
|
||||||
if (0 == num_results)
|
if (0 == num_results)
|
||||||
{
|
{
|
||||||
@ -1033,40 +1070,8 @@ taler_bank_get_history (void *cls,
|
|||||||
whh->hres_cb = hres_cb;
|
whh->hres_cb = hres_cb;
|
||||||
whh->hres_cb_cls = hres_cb_cls;
|
whh->hres_cb_cls = hres_cb_cls;
|
||||||
|
|
||||||
port = 443; /* if non given, equals 443. */
|
|
||||||
if (NULL != (p = strchr (account.hostname,
|
|
||||||
(unsigned char) ':')))
|
|
||||||
{
|
|
||||||
p++;
|
|
||||||
if (1 != sscanf (p,
|
|
||||||
"%llu",
|
|
||||||
&port))
|
|
||||||
{
|
|
||||||
GNUNET_break (0);
|
|
||||||
TALER_LOG_ERROR ("Malformed host from payto:// URI\n");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (443 != port)
|
|
||||||
{
|
|
||||||
GNUNET_assert
|
|
||||||
(GNUNET_SYSERR != GNUNET_asprintf
|
|
||||||
(&bank_base_url,
|
|
||||||
"http://%s",
|
|
||||||
account.hostname));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
GNUNET_assert
|
|
||||||
(GNUNET_SYSERR != GNUNET_asprintf
|
|
||||||
(&bank_base_url,
|
|
||||||
"https://%s",
|
|
||||||
account.hostname));
|
|
||||||
}
|
|
||||||
|
|
||||||
whh->hh = TALER_BANK_history (tc->ctx,
|
whh->hh = TALER_BANK_history (tc->ctx,
|
||||||
bank_base_url,
|
account.bank_base_url,
|
||||||
&whh->auth,
|
&whh->auth,
|
||||||
(uint64_t) account.no,
|
(uint64_t) account.no,
|
||||||
direction,
|
direction,
|
||||||
@ -1080,9 +1085,11 @@ taler_bank_get_history (void *cls,
|
|||||||
taler_bank_get_history_cancel (NULL,
|
taler_bank_get_history_cancel (NULL,
|
||||||
whh);
|
whh);
|
||||||
GNUNET_free (account.hostname);
|
GNUNET_free (account.hostname);
|
||||||
|
GNUNET_free (account.bank_base_url);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
GNUNET_free (account.hostname);
|
GNUNET_free (account.hostname);
|
||||||
|
GNUNET_free (account.bank_base_url);
|
||||||
return whh;
|
return whh;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user