-make purses_get compile
This commit is contained in:
parent
ae2f1ced8b
commit
8ef3997160
@ -50,6 +50,7 @@ libtalerexchange_la_SOURCES = \
|
|||||||
exchange_api_purse_create_with_merge.c \
|
exchange_api_purse_create_with_merge.c \
|
||||||
exchange_api_purse_deposit.c \
|
exchange_api_purse_deposit.c \
|
||||||
exchange_api_purse_merge.c \
|
exchange_api_purse_merge.c \
|
||||||
|
exchange_api_purses_get.c \
|
||||||
exchange_api_recoup.c \
|
exchange_api_recoup.c \
|
||||||
exchange_api_recoup_refresh.c \
|
exchange_api_recoup_refresh.c \
|
||||||
exchange_api_refresh_common.c exchange_api_refresh_common.h \
|
exchange_api_refresh_common.c exchange_api_refresh_common.h \
|
||||||
|
@ -35,7 +35,7 @@
|
|||||||
/**
|
/**
|
||||||
* @brief A Contract Get Handle
|
* @brief A Contract Get Handle
|
||||||
*/
|
*/
|
||||||
struct TALER_EXCHANGE_PursesGetHandle
|
struct TALER_EXCHANGE_PurseGetHandle
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -70,7 +70,7 @@ struct TALER_EXCHANGE_PursesGetHandle
|
|||||||
* Function called when we're done processing the
|
* Function called when we're done processing the
|
||||||
* HTTP /purses/$PID GET request.
|
* HTTP /purses/$PID GET request.
|
||||||
*
|
*
|
||||||
* @param cls the `struct TALER_EXCHANGE_PursesGetHandle`
|
* @param cls the `struct TALER_EXCHANGE_PurseGetHandle`
|
||||||
* @param response_code HTTP response code, 0 on error
|
* @param response_code HTTP response code, 0 on error
|
||||||
* @param response parsed JSON result, NULL on error
|
* @param response parsed JSON result, NULL on error
|
||||||
*/
|
*/
|
||||||
@ -79,14 +79,14 @@ handle_purse_get_finished (void *cls,
|
|||||||
long response_code,
|
long response_code,
|
||||||
const void *response)
|
const void *response)
|
||||||
{
|
{
|
||||||
struct TALER_EXCHANGE_PursesGetHandle *cgh = cls;
|
struct TALER_EXCHANGE_PurseGetHandle *pgh = cls;
|
||||||
const json_t *j = response;
|
const json_t *j = response;
|
||||||
struct TALER_EXCHANGE_PurseGetResponse dr = {
|
struct TALER_EXCHANGE_PurseGetResponse dr = {
|
||||||
.hr.reply = j,
|
.hr.reply = j,
|
||||||
.hr.http_status = (unsigned int) response_code
|
.hr.http_status = (unsigned int) response_code
|
||||||
};
|
};
|
||||||
|
|
||||||
cgh->job = NULL;
|
pgh->job = NULL;
|
||||||
switch (response_code)
|
switch (response_code)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
@ -112,9 +112,9 @@ handle_purse_get_finished (void *cls,
|
|||||||
dr.hr.ec = TALER_EC_GENERIC_REPLY_MALFORMED;
|
dr.hr.ec = TALER_EC_GENERIC_REPLY_MALFORMED;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
cgh->cb (cgh->cb_cls,
|
pgh->cb (pgh->cb_cls,
|
||||||
&dr);
|
&dr);
|
||||||
TALER_EXCHANGE_purse_get_cancel (cgh);
|
TALER_EXCHANGE_purse_get_cancel (pgh);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
case MHD_HTTP_BAD_REQUEST:
|
case MHD_HTTP_BAD_REQUEST:
|
||||||
@ -153,13 +153,13 @@ handle_purse_get_finished (void *cls,
|
|||||||
GNUNET_break_op (0);
|
GNUNET_break_op (0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
cgh->cb (cgh->cb_cls,
|
pgh->cb (pgh->cb_cls,
|
||||||
&dr);
|
&dr);
|
||||||
TALER_EXCHANGE_purse_get_cancel (cgh);
|
TALER_EXCHANGE_purse_get_cancel (pgh);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
struct TALER_EXCHANGE_PursesGetHandle *
|
struct TALER_EXCHANGE_PurseGetHandle *
|
||||||
TALER_EXCHANGE_purse_get (
|
TALER_EXCHANGE_purse_get (
|
||||||
struct TALER_EXCHANGE_Handle *exchange,
|
struct TALER_EXCHANGE_Handle *exchange,
|
||||||
const struct TALER_PurseContractPrivateKeyP *purse_priv,
|
const struct TALER_PurseContractPrivateKeyP *purse_priv,
|
||||||
@ -168,7 +168,7 @@ TALER_EXCHANGE_purse_get (
|
|||||||
TALER_EXCHANGE_PurseGetCallback cb,
|
TALER_EXCHANGE_PurseGetCallback cb,
|
||||||
void *cb_cls)
|
void *cb_cls)
|
||||||
{
|
{
|
||||||
struct TALER_EXCHANGE_PursesGetHandle *cgh;
|
struct TALER_EXCHANGE_PurseGetHandle *pgh;
|
||||||
CURL *eh;
|
CURL *eh;
|
||||||
struct TALER_PurseContractPublicKeyP purse_pub;
|
struct TALER_PurseContractPublicKeyP purse_pub;
|
||||||
char arg_str[sizeof (purse_pub) * 2 + 48];
|
char arg_str[sizeof (purse_pub) * 2 + 48];
|
||||||
@ -179,12 +179,12 @@ TALER_EXCHANGE_purse_get (
|
|||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
cgh = GNUNET_new (struct TALER_EXCHANGE_PursesGetHandle);
|
pgh = GNUNET_new (struct TALER_EXCHANGE_PurseGetHandle);
|
||||||
cgh->exchange = exchange;
|
pgh->exchange = exchange;
|
||||||
cgh->cb = cb;
|
pgh->cb = cb;
|
||||||
cgh->cb_cls = cb_cls;
|
pgh->cb_cls = cb_cls;
|
||||||
GNUNET_CRYPTO_ecdhe_key_get_public (&purse_priv->ecdhe_priv,
|
GNUNET_CRYPTO_eddsa_key_get_public (&purse_priv->eddsa_priv,
|
||||||
&purse_pub.ecdhe_pub);
|
&purse_pub.eddsa_pub);
|
||||||
{
|
{
|
||||||
char cpub_str[sizeof (purse_pub) * 2];
|
char cpub_str[sizeof (purse_pub) * 2];
|
||||||
char *end;
|
char *end;
|
||||||
@ -200,44 +200,44 @@ TALER_EXCHANGE_purse_get (
|
|||||||
cpub_str);
|
cpub_str);
|
||||||
}
|
}
|
||||||
|
|
||||||
cgh->url = TEAH_path_to_url (exchange,
|
pgh->url = TEAH_path_to_url (exchange,
|
||||||
arg_str);
|
arg_str);
|
||||||
if (NULL == cgh->url)
|
if (NULL == pgh->url)
|
||||||
{
|
{
|
||||||
GNUNET_free (cgh);
|
GNUNET_free (pgh);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
eh = TALER_EXCHANGE_curl_easy_get_ (cgh->url);
|
eh = TALER_EXCHANGE_curl_easy_get_ (pgh->url);
|
||||||
if (NULL == eh)
|
if (NULL == eh)
|
||||||
{
|
{
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
GNUNET_free (cgh->url);
|
GNUNET_free (pgh->url);
|
||||||
GNUNET_free (cgh);
|
GNUNET_free (pgh);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
/* FIXME: add signature with purse_priv
|
/* FIXME: add signature with purse_priv
|
||||||
to authorize the GET request!? Or
|
to authorize the GET request!? Or
|
||||||
decide it is non-critical and only
|
decide it is non-critical and only
|
||||||
pass purse_pub? */
|
pass purse_pub? */
|
||||||
cgh->job = GNUNET_CURL_job_add (TEAH_handle_to_context (exchange),
|
pgh->job = GNUNET_CURL_job_add (TEAH_handle_to_context (exchange),
|
||||||
eh,
|
eh,
|
||||||
&handle_purse_get_finished,
|
&handle_purse_get_finished,
|
||||||
cgh);
|
pgh);
|
||||||
return cgh;
|
return pgh;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TALER_EXCHANGE_purse_get_cancel (
|
TALER_EXCHANGE_purse_get_cancel (
|
||||||
struct TALER_EXCHANGE_PursesGetHandle *cgh)
|
struct TALER_EXCHANGE_PurseGetHandle *pgh)
|
||||||
{
|
{
|
||||||
if (NULL != cgh->job)
|
if (NULL != pgh->job)
|
||||||
{
|
{
|
||||||
GNUNET_CURL_job_cancel (cgh->job);
|
GNUNET_CURL_job_cancel (pgh->job);
|
||||||
cgh->job = NULL;
|
pgh->job = NULL;
|
||||||
}
|
}
|
||||||
GNUNET_free (cgh->url);
|
GNUNET_free (pgh->url);
|
||||||
GNUNET_free (cgh);
|
GNUNET_free (pgh);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user