summaryrefslogtreecommitdiff
path: root/src/exchange-lib/exchange_api_admin.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2016-04-17 17:45:15 +0200
committerChristian Grothoff <christian@grothoff.org>2016-04-17 17:45:15 +0200
commit1ed567a14b70ab49b720d176443479b340efb38c (patch)
tree4a52158f216ca128105101835aa85cecb843327b /src/exchange-lib/exchange_api_admin.c
parent05751b63aafb95047471a4e3bc19f3a06f474af3 (diff)
downloadexchange-1ed567a14b70ab49b720d176443479b340efb38c.tar.gz
exchange-1ed567a14b70ab49b720d176443479b340efb38c.tar.bz2
exchange-1ed567a14b70ab49b720d176443479b340efb38c.zip
replace exchange_api_context with libgnunetcurl
Diffstat (limited to 'src/exchange-lib/exchange_api_admin.c')
-rw-r--r--src/exchange-lib/exchange_api_admin.c44
1 files changed, 13 insertions, 31 deletions
diff --git a/src/exchange-lib/exchange_api_admin.c b/src/exchange-lib/exchange_api_admin.c
index 871a88a6..06a39ffa 100644
--- a/src/exchange-lib/exchange_api_admin.c
+++ b/src/exchange-lib/exchange_api_admin.c
@@ -25,9 +25,9 @@
#include <microhttpd.h> /* just for HTTP status codes */
#include <gnunet/gnunet_util_lib.h>
#include <gnunet/gnunet_json_lib.h>
+#include <gnunet/gnunet_curl_lib.h>
#include "taler_json_lib.h"
#include "taler_exchange_service.h"
-#include "exchange_api_context.h"
#include "exchange_api_handle.h"
#include "taler_signatures.h"
@@ -56,7 +56,7 @@ struct TALER_EXCHANGE_AdminAddIncomingHandle
/**
* Handle for the request.
*/
- struct MAC_Job *job;
+ struct GNUNET_CURL_Job *job;
/**
* HTTP headers for the request.
@@ -73,11 +73,6 @@ struct TALER_EXCHANGE_AdminAddIncomingHandle
*/
void *cb_cls;
- /**
- * Download buffer
- */
- struct MAC_DownloadBuffer db;
-
};
@@ -86,20 +81,17 @@ struct TALER_EXCHANGE_AdminAddIncomingHandle
* HTTP /admin/add/incoming request.
*
* @param cls the `struct TALER_EXCHANGE_AdminAddIncomingHandle`
- * @param eh the curl request handle
+ * @param response_code HTTP response code, 0 on error
+ * @param json parsed JSON result, NULL on error
*/
static void
handle_admin_add_incoming_finished (void *cls,
- CURL *eh)
+ long response_code,
+ const json_t *json)
{
struct TALER_EXCHANGE_AdminAddIncomingHandle *aai = cls;
- long response_code;
- json_t *json;
aai->job = NULL;
- json = MAC_download_get_result (&aai->db,
- eh,
- &response_code);
switch (response_code)
{
case 0:
@@ -138,7 +130,6 @@ handle_admin_add_incoming_finished (void *cls,
aai->cb (aai->cb_cls,
response_code,
json);
- json_decref (json);
TALER_EXCHANGE_admin_add_incoming_cancel (aai);
}
@@ -170,7 +161,7 @@ TALER_EXCHANGE_admin_add_incoming (struct TALER_EXCHANGE_Handle *exchange,
void *res_cb_cls)
{
struct TALER_EXCHANGE_AdminAddIncomingHandle *aai;
- struct TALER_EXCHANGE_Context *ctx;
+ struct GNUNET_CURL_Context *ctx;
json_t *admin_obj;
CURL *eh;
@@ -212,20 +203,12 @@ TALER_EXCHANGE_admin_add_incoming (struct TALER_EXCHANGE_Handle *exchange,
curl_easy_setopt (eh,
CURLOPT_POSTFIELDSIZE,
strlen (aai->json_enc)));
- GNUNET_assert (CURLE_OK ==
- curl_easy_setopt (eh,
- CURLOPT_WRITEFUNCTION,
- &MAC_download_cb));
- GNUNET_assert (CURLE_OK ==
- curl_easy_setopt (eh,
- CURLOPT_WRITEDATA,
- &aai->db));
ctx = MAH_handle_to_context (exchange);
- aai->job = MAC_job_add (ctx,
- eh,
- GNUNET_YES,
- &handle_admin_add_incoming_finished,
- aai);
+ aai->job = GNUNET_CURL_job_add (ctx,
+ eh,
+ GNUNET_YES,
+ &handle_admin_add_incoming_finished,
+ aai);
return aai;
}
@@ -241,11 +224,10 @@ TALER_EXCHANGE_admin_add_incoming_cancel (struct TALER_EXCHANGE_AdminAddIncoming
{
if (NULL != aai->job)
{
- MAC_job_cancel (aai->job);
+ GNUNET_CURL_job_cancel (aai->job);
aai->job = NULL;
}
curl_slist_free_all (aai->headers);
- GNUNET_free_non_null (aai->db.buf);
GNUNET_free (aai->url);
GNUNET_free (aai->json_enc);
GNUNET_free (aai);