denom->amount
This commit is contained in:
parent
a4cfbf3471
commit
12468e1fd8
@ -113,42 +113,43 @@ struct TALER_Amount
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse denomination description, in the format "T:V.F".
|
* Parse monetary amount, in the format "T:V.F".
|
||||||
*
|
*
|
||||||
* @param str denomination description
|
* @param str amount string
|
||||||
* @param[out] denom denomination to write the result to
|
* @param[out] amount amount to write the result to
|
||||||
* @return #GNUNET_OK if the string is a valid denomination specification,
|
* @return #GNUNET_OK if the string is a valid monetary amount specification,
|
||||||
* #GNUNET_SYSERR if it is invalid.
|
* #GNUNET_SYSERR if it is invalid.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_string_to_amount (const char *str,
|
TALER_string_to_amount (const char *str,
|
||||||
struct TALER_Amount *denom);
|
struct TALER_Amount *amount);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse denomination description, in the format "T:V.F".
|
* Parse monetary amount, in the format "T:V.F".
|
||||||
|
* The result is stored in network byte order (NBO).
|
||||||
*
|
*
|
||||||
* @param str denomination description
|
* @param str amount string
|
||||||
* @param[out] denom denomination to write the result to, in NBO
|
* @param[out] amount_nbo amount to write the result to
|
||||||
* @return #GNUNET_OK if the string is a valid denomination specification,
|
* @return #GNUNET_OK if the string is a valid amount specification,
|
||||||
* #GNUNET_SYSERR if it is invalid.
|
* #GNUNET_SYSERR if it is invalid.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_string_to_amount_nbo (const char *str,
|
TALER_string_to_amount_nbo (const char *str,
|
||||||
struct TALER_AmountNBO *denom);
|
struct TALER_AmountNBO *amount_nbo);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the value of "zero" in a particular currency.
|
* Get the value of "zero" in a particular currency.
|
||||||
*
|
*
|
||||||
* @param cur currency description
|
* @param cur currency description
|
||||||
* @param[out] denom denomination to write the result to
|
* @param[out] amount amount to write the result to
|
||||||
* @return #GNUNET_OK if @a cur is a valid currency specification,
|
* @return #GNUNET_OK if @a cur is a valid currency specification,
|
||||||
* #GNUNET_SYSERR if it is invalid.
|
* #GNUNET_SYSERR if it is invalid.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_amount_get_zero (const char *cur,
|
TALER_amount_get_zero (const char *cur,
|
||||||
struct TALER_Amount *denom);
|
struct TALER_Amount *amount);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -45,11 +45,11 @@ invalidate (struct TALER_Amount *a)
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse money amount description, in the format "A:B.C".
|
* Parse monetary amount, in the format "T:V.F".
|
||||||
*
|
*
|
||||||
* @param str amount description
|
* @param str amount string
|
||||||
* @param[out] denom amount to write the result to
|
* @param[out] amount amount to write the result to
|
||||||
* @return #GNUNET_OK if the string is a valid amount specification,
|
* @return #GNUNET_OK if the string is a valid monetary amount specification,
|
||||||
* #GNUNET_SYSERR if it is invalid.
|
* #GNUNET_SYSERR if it is invalid.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
@ -181,16 +181,17 @@ TALER_string_to_amount (const char *str,
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse denomination description, in the format "T:V.F".
|
* Parse monetary amount, in the format "T:V.F".
|
||||||
|
* The result is stored in network byte order (NBO).
|
||||||
*
|
*
|
||||||
* @param str denomination description
|
* @param str amount string
|
||||||
* @param[out] denom denomination to write the result to, in NBO
|
* @param[out] amount_nbo amount to write the result to
|
||||||
* @return #GNUNET_OK if the string is a valid denomination specification,
|
* @return #GNUNET_OK if the string is a valid amount specification,
|
||||||
* #GNUNET_SYSERR if it is invalid.
|
* #GNUNET_SYSERR if it is invalid.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_string_to_amount_nbo (const char *str,
|
TALER_string_to_amount_nbo (const char *str,
|
||||||
struct TALER_AmountNBO *denom)
|
struct TALER_AmountNBO *amount_nbo)
|
||||||
{
|
{
|
||||||
struct TALER_Amount amount;
|
struct TALER_Amount amount;
|
||||||
|
|
||||||
@ -198,7 +199,7 @@ TALER_string_to_amount_nbo (const char *str,
|
|||||||
TALER_string_to_amount (str,
|
TALER_string_to_amount (str,
|
||||||
&amount))
|
&amount))
|
||||||
return GNUNET_SYSERR;
|
return GNUNET_SYSERR;
|
||||||
TALER_amount_hton (denom,
|
TALER_amount_hton (amount_nbo,
|
||||||
&amount);
|
&amount);
|
||||||
return GNUNET_OK;
|
return GNUNET_OK;
|
||||||
}
|
}
|
||||||
@ -248,23 +249,23 @@ TALER_amount_ntoh (struct TALER_Amount *res,
|
|||||||
* Get the value of "zero" in a particular currency.
|
* Get the value of "zero" in a particular currency.
|
||||||
*
|
*
|
||||||
* @param cur currency description
|
* @param cur currency description
|
||||||
* @param[out] denom denomination to write the result to
|
* @param[out] amount amount to write the result to
|
||||||
* @return #GNUNET_OK if @a cur is a valid currency specification,
|
* @return #GNUNET_OK if @a cur is a valid currency specification,
|
||||||
* #GNUNET_SYSERR if it is invalid.
|
* #GNUNET_SYSERR if it is invalid.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_amount_get_zero (const char *cur,
|
TALER_amount_get_zero (const char *cur,
|
||||||
struct TALER_Amount *denom)
|
struct TALER_Amount *amount)
|
||||||
{
|
{
|
||||||
size_t slen;
|
size_t slen;
|
||||||
|
|
||||||
slen = strlen (cur);
|
slen = strlen (cur);
|
||||||
if (slen >= TALER_CURRENCY_LEN)
|
if (slen >= TALER_CURRENCY_LEN)
|
||||||
return GNUNET_SYSERR;
|
return GNUNET_SYSERR;
|
||||||
memset (denom,
|
memset (amount,
|
||||||
0,
|
0,
|
||||||
sizeof (struct TALER_Amount));
|
sizeof (struct TALER_Amount));
|
||||||
memcpy (denom->currency,
|
memcpy (amount->currency,
|
||||||
cur,
|
cur,
|
||||||
slen);
|
slen);
|
||||||
return GNUNET_OK;
|
return GNUNET_OK;
|
||||||
|
Loading…
Reference in New Issue
Block a user