summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcello Stanisci <stanisci.m@gmail.com>2018-11-20 15:42:37 +0100
committerMarcello Stanisci <stanisci.m@gmail.com>2018-11-20 15:59:23 +0100
commitd6937b51f7b4dd5ccec91fe490773525080903dd (patch)
treec2f25d48e613c1e1ca3b91febeeb815f9052fe40
parente592a116e0bda2eff841b462cbf02fdb3e0d5b29 (diff)
downloadmerchant-d6937b51f7b4dd5ccec91fe490773525080903dd.tar.gz
merchant-d6937b51f7b4dd5ccec91fe490773525080903dd.tar.bz2
merchant-d6937b51f7b4dd5ccec91fe490773525080903dd.zip
Fix compilation warnings, due to:
1) abstraction on the response type from the CURL-needed callbacks. 2) converting the contract terms trait into a JSON object.
-rw-r--r--src/lib/merchant_api_check_payment.c3
-rw-r--r--src/lib/merchant_api_history.c3
-rw-r--r--src/lib/merchant_api_pay.c3
-rw-r--r--src/lib/merchant_api_proposal.c8
-rw-r--r--src/lib/merchant_api_refund.c6
-rw-r--r--src/lib/merchant_api_tip_authorize.c3
-rw-r--r--src/lib/merchant_api_tip_pickup.c3
-rw-r--r--src/lib/merchant_api_tip_query.c3
-rw-r--r--src/lib/merchant_api_track_transaction.c3
-rw-r--r--src/lib/merchant_api_track_transfer.c3
-rw-r--r--src/lib/testing_api_cmd_pay.c27
-rw-r--r--src/lib/testing_api_cmd_proposal.c14
-rw-r--r--src/lib/testing_api_cmd_refund.c4
-rw-r--r--src/lib/testing_api_cmd_tip.c6
-rw-r--r--src/lib/testing_api_cmd_track.c4
-rw-r--r--src/lib/testing_api_trait_hash.c4
-rw-r--r--src/lib/testing_api_trait_merchant_sig.c2
-rw-r--r--src/lib/testing_api_trait_planchet.c2
-rw-r--r--src/lib/testing_api_trait_refund_entry.c2
-rw-r--r--src/lib/testing_api_trait_string.c4
20 files changed, 58 insertions, 49 deletions
diff --git a/src/lib/merchant_api_check_payment.c b/src/lib/merchant_api_check_payment.c
index 98e844de..eb5c4202 100644
--- a/src/lib/merchant_api_check_payment.c
+++ b/src/lib/merchant_api_check_payment.c
@@ -75,11 +75,12 @@ struct TALER_MERCHANT_CheckPaymentOperation
static void
handle_check_payment_finished (void *cls,
long response_code,
- const json_t *json)
+ const void *response)
{
struct TALER_MERCHANT_CheckPaymentOperation *cpo = cls;
struct TALER_Amount refund_amount = { 0 };
int refunded;
+ const json_t *json = response;
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_boolean ("refunded",
diff --git a/src/lib/merchant_api_history.c b/src/lib/merchant_api_history.c
index 38a08671..17e08f09 100644
--- a/src/lib/merchant_api_history.c
+++ b/src/lib/merchant_api_history.c
@@ -91,9 +91,10 @@ TALER_MERCHANT_history_cancel (struct TALER_MERCHANT_HistoryOperation *ho)
static void
history_raw_cb (void *cls,
long response_code,
- const json_t *json)
+ const void *response)
{
struct TALER_MERCHANT_HistoryOperation *ho = cls;
+ const json_t *json = response;
ho->job = NULL;
switch (response_code)
diff --git a/src/lib/merchant_api_pay.c b/src/lib/merchant_api_pay.c
index 93b6478a..be70f6d4 100644
--- a/src/lib/merchant_api_pay.c
+++ b/src/lib/merchant_api_pay.c
@@ -321,9 +321,10 @@ check_forbidden (struct TALER_MERCHANT_Pay *ph,
static void
handle_pay_finished (void *cls,
long response_code,
- const json_t *json)
+ const void *response)
{
struct TALER_MERCHANT_Pay *ph = cls;
+ const json_t *json = response;
ph->job = NULL;
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
diff --git a/src/lib/merchant_api_proposal.c b/src/lib/merchant_api_proposal.c
index 72b44fa8..3d7218c6 100644
--- a/src/lib/merchant_api_proposal.c
+++ b/src/lib/merchant_api_proposal.c
@@ -122,10 +122,12 @@ struct TALER_MERCHANT_ProposalLookupOperation
static void
handle_proposal_finished (void *cls,
long response_code,
- const json_t *json)
+ const void *response)
{
struct TALER_MERCHANT_ProposalOperation *po = cls;
const char *order_id;
+ const json_t *json = response;
+
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_string ("order_id",
&order_id),
@@ -264,12 +266,14 @@ TALER_MERCHANT_order_put (struct GNUNET_CURL_Context *ctx,
static void
handle_proposal_lookup_finished (void *cls,
long response_code,
- const json_t *json)
+ const void *response)
{
struct TALER_MERCHANT_ProposalLookupOperation *plo = cls;
json_t *contract_terms;
struct TALER_MerchantSignatureP sig;
struct GNUNET_HashCode hash;
+ const json_t *json = response;
+
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_json ("contract_terms",
&contract_terms),
diff --git a/src/lib/merchant_api_refund.c b/src/lib/merchant_api_refund.c
index e724108c..993c815f 100644
--- a/src/lib/merchant_api_refund.c
+++ b/src/lib/merchant_api_refund.c
@@ -106,12 +106,13 @@ struct TALER_MERCHANT_RefundIncreaseOperation
static void
handle_refund_increase_finished (void *cls,
long response_code,
- const json_t *json)
+ const void *response)
{
struct TALER_MERCHANT_RefundIncreaseOperation *rio = cls;
char *error;
char *hint;
enum TALER_ErrorCode code;
+ const json_t *json = response;
rio->job = NULL;
switch (response_code)
@@ -271,11 +272,12 @@ TALER_MERCHANT_refund_lookup_cancel (struct TALER_MERCHANT_RefundLookupOperation
static void
handle_refund_lookup_finished (void *cls,
long response_code,
- const json_t *json)
+ const void *response)
{
struct TALER_MERCHANT_RefundLookupOperation *rlo = cls;
char *error;
enum TALER_ErrorCode code;
+ const json_t *json = response;
rlo->job = NULL;
switch (response_code)
diff --git a/src/lib/merchant_api_tip_authorize.c b/src/lib/merchant_api_tip_authorize.c
index f27d06f8..268db3c1 100644
--- a/src/lib/merchant_api_tip_authorize.c
+++ b/src/lib/merchant_api_tip_authorize.c
@@ -123,9 +123,10 @@ check_ok (struct TALER_MERCHANT_TipAuthorizeOperation *tao,
static void
handle_tip_authorize_finished (void *cls,
long response_code,
- const json_t *json)
+ const void *response)
{
struct TALER_MERCHANT_TipAuthorizeOperation *tao = cls;
+ const json_t *json = response;
tao->job = NULL;
switch (response_code)
diff --git a/src/lib/merchant_api_tip_pickup.c b/src/lib/merchant_api_tip_pickup.c
index 3bf38e48..8785384c 100644
--- a/src/lib/merchant_api_tip_pickup.c
+++ b/src/lib/merchant_api_tip_pickup.c
@@ -156,9 +156,10 @@ check_ok (struct TALER_MERCHANT_TipPickupOperation *tpo,
static void
handle_tip_pickup_finished (void *cls,
long response_code,
- const json_t *json)
+ const void *response)
{
struct TALER_MERCHANT_TipPickupOperation *tpo = cls;
+ const json_t *json = response;
tpo->job = NULL;
switch (response_code)
diff --git a/src/lib/merchant_api_tip_query.c b/src/lib/merchant_api_tip_query.c
index b0b2c194..842fa682 100644
--- a/src/lib/merchant_api_tip_query.c
+++ b/src/lib/merchant_api_tip_query.c
@@ -131,9 +131,10 @@ check_ok (struct TALER_MERCHANT_TipQueryOperation *tqo,
static void
handle_tip_query_finished (void *cls,
long response_code,
- const json_t *json)
+ const void *response)
{
struct TALER_MERCHANT_TipQueryOperation *tqo = cls;
+ const json_t *json = response;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Got /tip-query response with status code %u\n",
diff --git a/src/lib/merchant_api_track_transaction.c b/src/lib/merchant_api_track_transaction.c
index ae5d903f..32393ece 100644
--- a/src/lib/merchant_api_track_transaction.c
+++ b/src/lib/merchant_api_track_transaction.c
@@ -76,9 +76,10 @@ struct TALER_MERCHANT_TrackTransactionHandle
static void
handle_track_transaction_finished (void *cls,
long response_code,
- const json_t *json)
+ const void *response)
{
struct TALER_MERCHANT_TrackTransactionHandle *tdo = cls;
+ const json_t *json = response;
tdo->job = NULL;
switch (response_code)
diff --git a/src/lib/merchant_api_track_transfer.c b/src/lib/merchant_api_track_transfer.c
index 5766a57c..8c8121a4 100644
--- a/src/lib/merchant_api_track_transfer.c
+++ b/src/lib/merchant_api_track_transfer.c
@@ -159,9 +159,10 @@ check_track_transfer_response_ok (struct TALER_MERCHANT_TrackTransferHandle *wdh
static void
handle_track_transfer_finished (void *cls,
long response_code,
- const json_t *json)
+ const void *response)
{
struct TALER_MERCHANT_TrackTransferHandle *tdo = cls;
+ const json_t *json = response;
tdo->job = NULL;
switch (response_code)
diff --git a/src/lib/testing_api_cmd_pay.c b/src/lib/testing_api_cmd_pay.c
index de7000d0..80f9d08e 100644
--- a/src/lib/testing_api_cmd_pay.c
+++ b/src/lib/testing_api_cmd_pay.c
@@ -533,8 +533,8 @@ build_coins (struct TALER_MERCHANT_PayCoin **pc,
icoin = &(*pc)[(*npc)-1];
- struct TALER_CoinSpendPrivateKeyP *coin_priv;
- struct TALER_DenominationSignature *denom_sig;
+ const struct TALER_CoinSpendPrivateKeyP *coin_priv;
+ const struct TALER_DenominationSignature *denom_sig;
const struct TALER_Amount *denom_value;
const struct TALER_EXCHANGE_DenomPublicKey *denom_pub;
@@ -770,7 +770,7 @@ _pay_run (const char *merchant_url,
{
json_t *ct;
const struct TALER_TESTING_Command *proposal_cmd;
- const char *contract_terms;
+ const json_t *contract_terms;
const char *order_id;
struct GNUNET_TIME_Absolute refund_deadline;
struct GNUNET_TIME_Absolute pay_deadline;
@@ -804,15 +804,6 @@ _pay_run (const char *merchant_url,
return NULL;
}
- json_error_t error;
- if (NULL ==
- (ct = json_loads (contract_terms,
- JSON_COMPACT,
- &error)))
- {
- GNUNET_break (0);
- return NULL;
- }
/* Get information that needs to be put verbatim in the
* deposit permission */
struct GNUNET_JSON_Specification spec[] = {
@@ -835,7 +826,7 @@ _pay_run (const char *merchant_url,
GNUNET_JSON_spec_end()
};
if (GNUNET_OK !=
- GNUNET_JSON_parse (ct,
+ GNUNET_JSON_parse (contract_terms,
spec,
&error_name,
&error_line))
@@ -844,7 +835,9 @@ _pay_run (const char *merchant_url,
"Parser failed on %s:%u\n",
error_name,
error_line);
- fprintf (stderr, "%s\n", contract_terms);
+ fprintf (stderr, "%s\n",
+ json_dumps (contract_terms,
+ JSON_INDENT (1)));
GNUNET_break_op (0);
json_decref (ct);
return NULL;
@@ -977,7 +970,7 @@ pay_cleanup (void *cls,
*/
static int
pay_traits (void *cls,
- void **ret,
+ const void **ret,
const char *trait,
unsigned int index)
{
@@ -1187,7 +1180,7 @@ pay_abort_run (void *cls,
*/
static int
pay_abort_traits (void *cls,
- void **ret,
+ const void **ret,
const char *trait,
unsigned int index)
{
@@ -1530,7 +1523,7 @@ pay_abort_refund_run (void *cls,
struct TALER_Amount refund_fee;
struct TALER_Amount refund_amount;
const struct TALER_MERCHANT_RefundEntry *refund_entry;
- unsigned int *num_refunds;
+ const unsigned int *num_refunds;
const struct TALER_TESTING_Command *abort_cmd;
const struct GNUNET_CRYPTO_EddsaPublicKey *merchant_pub;
const struct GNUNET_HashCode *h_contract_terms;
diff --git a/src/lib/testing_api_cmd_proposal.c b/src/lib/testing_api_cmd_proposal.c
index dcd3b3e3..fb22c52f 100644
--- a/src/lib/testing_api_cmd_proposal.c
+++ b/src/lib/testing_api_cmd_proposal.c
@@ -53,7 +53,7 @@ struct ProposalState
/**
* Contract terms obtained from the backend.
*/
- const char *contract_terms;
+ json_t *contract_terms;
/**
* Contract terms hash code.
@@ -165,7 +165,7 @@ struct ProposalLookupState
*/
static int
proposal_traits (void *cls,
- void **ret,
+ const void **ret,
const char *trait,
unsigned int index)
{
@@ -222,8 +222,7 @@ proposal_lookup_initial_cb
if (ps->http_status != http_status)
TALER_TESTING_FAIL (ps->is);
- ps->contract_terms = json_dumps (contract_terms,
- JSON_COMPACT);
+ ps->contract_terms = json_deep_copy (contract_terms);
ps->h_contract_terms = *hash;
ps->merchant_sig = *sig;
@@ -244,7 +243,10 @@ proposal_lookup_initial_cb
"Parser failed on %s:%u\n",
error_name,
error_line);
- fprintf (stderr, "%s\n", ps->contract_terms);
+ fprintf (stderr,
+ "%s\n",
+ json_dumps (ps->contract_terms,
+ JSON_INDENT (1)));
TALER_TESTING_FAIL (ps->is);
}
@@ -433,8 +435,8 @@ proposal_cleanup (void *cls,
ps->plo = NULL;
}
+ json_decref (ps->contract_terms);
GNUNET_free_non_null ((void *) ps->order_id);
- GNUNET_free_non_null ((void *) ps->contract_terms);
GNUNET_free (ps);
}
diff --git a/src/lib/testing_api_cmd_refund.c b/src/lib/testing_api_cmd_refund.c
index 45b493df..8adb77d7 100644
--- a/src/lib/testing_api_cmd_refund.c
+++ b/src/lib/testing_api_cmd_refund.c
@@ -350,7 +350,7 @@ refund_lookup_cb (void *cls,
NULL != icoin_reference;
icoin_reference = strtok (NULL, ";"))
{
- struct TALER_CoinSpendPrivateKeyP *icoin_priv;
+ const struct TALER_CoinSpendPrivateKeyP *icoin_priv;
struct TALER_CoinSpendPublicKeyP icoin_pub;
struct GNUNET_HashCode h_icoin_pub;
struct TALER_Amount *iamount;
@@ -477,7 +477,7 @@ refund_lookup_run (void *cls,
*/
static int
refund_increase_traits (void *cls,
- void **ret,
+ const void **ret,
const char *trait,
unsigned int index)
{
diff --git a/src/lib/testing_api_cmd_tip.c b/src/lib/testing_api_cmd_tip.c
index e9a2842f..f6a8f843 100644
--- a/src/lib/testing_api_cmd_tip.c
+++ b/src/lib/testing_api_cmd_tip.c
@@ -347,7 +347,7 @@ tip_authorize_cb (void *cls,
*/
static int
tip_authorize_traits (void *cls,
- void **ret,
+ const void **ret,
const char *trait,
unsigned int index)
{
@@ -970,7 +970,7 @@ tip_pickup_run (void *cls,
}
else
{
- unsigned int *np;
+ const unsigned int *np;
if ( NULL == /* looking for "parent" tip-pickup command */
( replay_cmd = TALER_TESTING_interpreter_lookup_command
(is, tps->replay_reference)) )
@@ -1093,7 +1093,7 @@ tip_pickup_cleanup (void *cls,
*/
static int
tip_pickup_traits (void *cls,
- void **ret,
+ const void **ret,
const char *trait,
unsigned int index)
{
diff --git a/src/lib/testing_api_cmd_track.c b/src/lib/testing_api_cmd_track.c
index e0c43c14..e90a942f 100644
--- a/src/lib/testing_api_cmd_track.c
+++ b/src/lib/testing_api_cmd_track.c
@@ -268,7 +268,7 @@ track_transfer_run (void *cls,
struct TALER_TESTING_Interpreter *is)
{
struct TrackTransferState *tts = cls;
- struct TALER_WireTransferIdentifierRawP *wtid;
+ const struct TALER_WireTransferIdentifierRawP *wtid;
const struct TALER_TESTING_Command *check_bank_cmd;
const char *exchange_url;
@@ -399,7 +399,7 @@ track_transaction_cleanup (void *cls,
*/
static int
track_transaction_traits (void *cls,
- void **ret,
+ const void **ret,
const char *trait,
unsigned int index)
{
diff --git a/src/lib/testing_api_trait_hash.c b/src/lib/testing_api_trait_hash.c
index b1516cfb..79cd38e3 100644
--- a/src/lib/testing_api_trait_hash.c
+++ b/src/lib/testing_api_trait_hash.c
@@ -52,7 +52,7 @@ TALER_TESTING_get_trait_tip_id
struct GNUNET_HashCode **tip_id)
{
return cmd->traits (cmd->cls,
- (void **) tip_id,
+ (const void **) tip_id,
TALER_TESTING_TRAIT_TIP_ID,
index);
}
@@ -96,7 +96,7 @@ TALER_TESTING_get_trait_h_contract_terms
const struct GNUNET_HashCode **h_contract_terms)
{
return cmd->traits (cmd->cls,
- (void **) h_contract_terms,
+ (const void **) h_contract_terms,
TALER_TESTING_TRAIT_H_CONTRACT_TERMS,
index);
}
diff --git a/src/lib/testing_api_trait_merchant_sig.c b/src/lib/testing_api_trait_merchant_sig.c
index c42260ab..2f39f531 100644
--- a/src/lib/testing_api_trait_merchant_sig.c
+++ b/src/lib/testing_api_trait_merchant_sig.c
@@ -45,7 +45,7 @@ TALER_TESTING_get_trait_merchant_sig
struct TALER_MerchantSignatureP **merchant_sig)
{
return cmd->traits (cmd->cls,
- (void **) merchant_sig,
+ (const void **) merchant_sig,
TALER_TESTING_TRAIT_MERCHANT_SIG,
index);
}
diff --git a/src/lib/testing_api_trait_planchet.c b/src/lib/testing_api_trait_planchet.c
index 8a20188f..3c8a6dca 100644
--- a/src/lib/testing_api_trait_planchet.c
+++ b/src/lib/testing_api_trait_planchet.c
@@ -44,7 +44,7 @@ TALER_TESTING_get_trait_planchet_secrets
struct TALER_PlanchetSecretsP **planchet_secrets)
{
return cmd->traits (cmd->cls,
- (void **) planchet_secrets,
+ (const void **) planchet_secrets,
TALER_TESTING_TRAIT_PLANCHET_SECRETS,
index);
}
diff --git a/src/lib/testing_api_trait_refund_entry.c b/src/lib/testing_api_trait_refund_entry.c
index 2ba1a90f..502c0875 100644
--- a/src/lib/testing_api_trait_refund_entry.c
+++ b/src/lib/testing_api_trait_refund_entry.c
@@ -47,7 +47,7 @@ TALER_TESTING_get_trait_refund_entry
const struct TALER_MERCHANT_RefundEntry **refund_entry)
{
return cmd->traits (cmd->cls,
- (void **) refund_entry,
+ (const void **) refund_entry,
TALER_TESTING_TRAIT_REFUND_ENTRY,
index);
}
diff --git a/src/lib/testing_api_trait_string.c b/src/lib/testing_api_trait_string.c
index 0534b701..226428e7 100644
--- a/src/lib/testing_api_trait_string.c
+++ b/src/lib/testing_api_trait_string.c
@@ -51,7 +51,7 @@ TALER_TESTING_get_trait_proposal_reference
const char **proposal_reference)
{
return cmd->traits (cmd->cls,
- (void **) proposal_reference,
+ (const void **) proposal_reference,
TALER_TESTING_TRAIT_PROPOSAL_REFERENCE,
index);
}
@@ -104,7 +104,7 @@ TALER_TESTING_get_trait_coin_reference
const char **coin_reference)
{
return cmd->traits (cmd->cls,
- (void **) coin_reference,
+ (const void **) coin_reference,
TALER_TESTING_TRAIT_COIN_REFERENCE,
index);
}