diff options
Diffstat (limited to 'src/lib')
23 files changed, 179 insertions, 253 deletions
| diff --git a/src/lib/exchange_api_add_aml_decision.c b/src/lib/exchange_api_add_aml_decision.c index 7245db3b..342e1e3d 100644 --- a/src/lib/exchange_api_add_aml_decision.c +++ b/src/lib/exchange_api_add_aml_decision.c @@ -79,9 +79,9 @@ handle_add_aml_decision_finished (void *cls,  {    struct TALER_EXCHANGE_AddAmlDecision *wh = cls;    const json_t *json = response; -  struct TALER_EXCHANGE_HttpResponse hr = { -    .http_status = (unsigned int) response_code, -    .reply = json +  struct TALER_EXCHANGE_AddAmlDecisionResponse adr = { +    .hr.http_status = (unsigned int) response_code, +    .hr.reply = json    };    wh->job = NULL; @@ -89,34 +89,34 @@ handle_add_aml_decision_finished (void *cls,    {    case 0:      /* no reply */ -    hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE; -    hr.hint = "server offline?"; +    adr.hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE; +    adr.hr.hint = "server offline?";      break;    case MHD_HTTP_NO_CONTENT:      break;    case MHD_HTTP_FORBIDDEN: -    hr.ec = TALER_JSON_get_error_code (json); -    hr.hint = TALER_JSON_get_error_hint (json); +    adr.hr.ec = TALER_JSON_get_error_code (json); +    adr.hr.hint = TALER_JSON_get_error_hint (json);      break;    case MHD_HTTP_CONFLICT: -    hr.ec = TALER_JSON_get_error_code (json); -    hr.hint = TALER_JSON_get_error_hint (json); +    adr.hr.ec = TALER_JSON_get_error_code (json); +    adr.hr.hint = TALER_JSON_get_error_hint (json);      break;    default:      /* unexpected response code */      GNUNET_break_op (0); -    hr.ec = TALER_JSON_get_error_code (json); -    hr.hint = TALER_JSON_get_error_hint (json); +    adr.hr.ec = TALER_JSON_get_error_code (json); +    adr.hr.hint = TALER_JSON_get_error_hint (json);      GNUNET_log (GNUNET_ERROR_TYPE_ERROR,                  "Unexpected response code %u/%d for exchange AML decision\n",                  (unsigned int) response_code, -                (int) hr.ec); +                (int) adr.hr.ec);      break;    }    if (NULL != wh->cb)    {      wh->cb (wh->cb_cls, -            &hr); +            &adr);      wh->cb = NULL;    }    TALER_EXCHANGE_add_aml_decision_cancel (wh); diff --git a/src/lib/exchange_api_auditor_add_denomination.c b/src/lib/exchange_api_auditor_add_denomination.c index 71f421d4..89de0d7f 100644 --- a/src/lib/exchange_api_auditor_add_denomination.c +++ b/src/lib/exchange_api_auditor_add_denomination.c @@ -79,9 +79,9 @@ handle_auditor_add_denomination_finished (void *cls,  {    struct TALER_EXCHANGE_AuditorAddDenominationHandle *ah = cls;    const json_t *json = response; -  struct TALER_EXCHANGE_HttpResponse hr = { -    .http_status = (unsigned int) response_code, -    .reply = json +  struct TALER_EXCHANGE_AuditorAddDenominationResponse adr = { +    .hr.http_status = (unsigned int) response_code, +    .hr.reply = json    };    ah->job = NULL; @@ -90,37 +90,37 @@ handle_auditor_add_denomination_finished (void *cls,    case MHD_HTTP_NO_CONTENT:      break;    case MHD_HTTP_FORBIDDEN: -    hr.ec = TALER_JSON_get_error_code (json); -    hr.hint = TALER_JSON_get_error_hint (json); +    adr.hr.ec = TALER_JSON_get_error_code (json); +    adr.hr.hint = TALER_JSON_get_error_hint (json);      break;    case MHD_HTTP_NOT_FOUND: -    hr.ec = TALER_JSON_get_error_code (json); -    hr.hint = TALER_JSON_get_error_hint (json); +    adr.hr.ec = TALER_JSON_get_error_code (json); +    adr.hr.hint = TALER_JSON_get_error_hint (json);      break;    case MHD_HTTP_GONE: -    hr.ec = TALER_JSON_get_error_code (json); -    hr.hint = TALER_JSON_get_error_hint (json); +    adr.hr.ec = TALER_JSON_get_error_code (json); +    adr.hr.hint = TALER_JSON_get_error_hint (json);      break;    case MHD_HTTP_PRECONDITION_FAILED: -    hr.ec = TALER_JSON_get_error_code (json); -    hr.hint = TALER_JSON_get_error_hint (json); +    adr.hr.ec = TALER_JSON_get_error_code (json); +    adr.hr.hint = TALER_JSON_get_error_hint (json);      break;    default:      /* unexpected response code */      if (NULL != json)      { -      hr.ec = TALER_JSON_get_error_code (json); -      hr.hint = TALER_JSON_get_error_hint (json); +      adr.hr.ec = TALER_JSON_get_error_code (json); +      adr.hr.hint = TALER_JSON_get_error_hint (json);        GNUNET_log (GNUNET_ERROR_TYPE_ERROR,                    "Unexpected response code %u/%d for exchange auditor-add-denomination at URL `%s'\n",                    (unsigned int) response_code, -                  (int) hr.ec, +                  (int) adr.hr.ec,                    ah->url);      }      else      { -      hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE; -      hr.hint = NULL; +      adr.hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE; +      adr.hr.hint = NULL;        GNUNET_log (GNUNET_ERROR_TYPE_ERROR,                    "Unexpected HTTP response code %u (no JSON returned) at URL `%s'\n",                    (unsigned int) response_code, @@ -131,7 +131,7 @@ handle_auditor_add_denomination_finished (void *cls,    if (NULL != ah->cb)    {      ah->cb (ah->cb_cls, -            &hr); +            &adr);      ah->cb = NULL;    }    TALER_EXCHANGE_add_auditor_denomination_cancel (ah); diff --git a/src/lib/exchange_api_batch_deposit.c b/src/lib/exchange_api_batch_deposit.c index c583d5ad..544407a3 100644 --- a/src/lib/exchange_api_batch_deposit.c +++ b/src/lib/exchange_api_batch_deposit.c @@ -237,12 +237,12 @@ handle_deposit_finished (void *cls,    case MHD_HTTP_OK:      {        const struct TALER_EXCHANGE_Keys *key_state; -      json_t *sigs; +      const json_t *sigs;        json_t *sig;        unsigned int idx;        struct GNUNET_JSON_Specification spec[] = { -        GNUNET_JSON_spec_json ("exchange_sigs", -                               &sigs), +        GNUNET_JSON_spec_array_const ("exchange_sigs", +                                      &sigs),          GNUNET_JSON_spec_fixed_auto ("exchange_pub",                                       &dh->exchange_pub),          GNUNET_JSON_spec_mark_optional ( @@ -269,7 +269,6 @@ handle_deposit_finished (void *cls,          GNUNET_break_op (0);          dr.hr.http_status = 0;          dr.hr.ec = TALER_EC_GENERIC_REPLY_MALFORMED; -        GNUNET_JSON_parse_free (spec);          break;        }        dh->exchange_sigs = GNUNET_new_array (dh->num_cdds, @@ -282,7 +281,6 @@ handle_deposit_finished (void *cls,          GNUNET_break_op (0);          dr.hr.http_status = 0;          dr.hr.ec = TALER_EC_EXCHANGE_DEPOSIT_INVALID_SIGNATURE_BY_EXCHANGE; -        GNUNET_JSON_parse_free (spec);          break;        }        json_array_foreach (sigs, idx, sig) @@ -303,7 +301,6 @@ handle_deposit_finished (void *cls,            GNUNET_break_op (0);            dr.hr.http_status = 0;            dr.hr.ec = TALER_EC_GENERIC_REPLY_MALFORMED; -          GNUNET_JSON_parse_free (spec);            break;          }          dki = TALER_EXCHANGE_get_denomination_key_by_hash (key_state, @@ -332,14 +329,12 @@ handle_deposit_finished (void *cls,            GNUNET_break_op (0);            dr.hr.http_status = 0;            dr.hr.ec = TALER_EC_EXCHANGE_DEPOSIT_INVALID_SIGNATURE_BY_EXCHANGE; -          GNUNET_JSON_parse_free (spec);            break;          }        }        TEAH_get_auditors_for_dc (dh->exchange,                                  &auditor_cb,                                  dh); -      GNUNET_JSON_parse_free (spec);      }      dr.details.ok.exchange_sigs = dh->exchange_sigs;      dr.details.ok.exchange_pub = &dh->exchange_pub; diff --git a/src/lib/exchange_api_common.c b/src/lib/exchange_api_common.c index 588b1283..8bbc6c47 100644 --- a/src/lib/exchange_api_common.c +++ b/src/lib/exchange_api_common.c @@ -1465,7 +1465,7 @@ enum GNUNET_GenericReturnValue  TALER_EXCHANGE_verify_coin_history (    const struct TALER_EXCHANGE_DenomPublicKey *dk,    const struct TALER_CoinSpendPublicKeyP *coin_pub, -  json_t *history, +  const json_t *history,    struct TALER_Amount *total)  {    const char *currency = dk->value.currency; @@ -1865,7 +1865,7 @@ TALER_EXCHANGE_check_coin_amount_conflict_ (    struct TALER_CoinSpendPublicKeyP *coin_pub,    struct TALER_Amount *remaining)  { -  json_t *history; +  const json_t *history;    struct TALER_Amount total;    struct TALER_DenominationHashP h_denom_pub;    const struct TALER_EXCHANGE_DenomPublicKey *dki; @@ -1874,8 +1874,8 @@ TALER_EXCHANGE_check_coin_amount_conflict_ (                                   coin_pub),      GNUNET_JSON_spec_fixed_auto ("h_denom_pub",                                   &h_denom_pub), -    GNUNET_JSON_spec_json ("history", -                           &history), +    GNUNET_JSON_spec_array_const ("history", +                                  &history),      GNUNET_JSON_spec_end ()    }; @@ -1902,10 +1902,8 @@ TALER_EXCHANGE_check_coin_amount_conflict_ (                                            &total))    {      GNUNET_break_op (0); -    json_decref (history);      return GNUNET_SYSERR;    } -  json_decref (history);    if (0 >        TALER_amount_subtract (remaining,                               &dki->value, @@ -2298,8 +2296,8 @@ TALER_EXCHANGE_parse_accounts (const struct TALER_MasterPublicKeyP *master_pub,         i++)    {      struct TALER_EXCHANGE_WireAccount *wa = &was[i]; -    json_t *credit_restrictions; -    json_t *debit_restrictions; +    const json_t *credit_restrictions; +    const json_t *debit_restrictions;      struct GNUNET_JSON_Specification spec_account[] = {        GNUNET_JSON_spec_string ("payto_uri",                                 &wa->payto_uri), @@ -2307,10 +2305,10 @@ TALER_EXCHANGE_parse_accounts (const struct TALER_MasterPublicKeyP *master_pub,          GNUNET_JSON_spec_string ("conversion_url",                                   &wa->conversion_url),          NULL), -      GNUNET_JSON_spec_json ("credit_restrictions", -                             &credit_restrictions), -      GNUNET_JSON_spec_json ("debit_restrictions", -                             &debit_restrictions), +      GNUNET_JSON_spec_array_const ("credit_restrictions", +                                    &credit_restrictions), +      GNUNET_JSON_spec_array_const ("debit_restrictions", +                                    &debit_restrictions),        GNUNET_JSON_spec_fixed_auto ("master_sig",                                     &wa->master_sig),        GNUNET_JSON_spec_end () @@ -2366,7 +2364,6 @@ TALER_EXCHANGE_parse_accounts (const struct TALER_MasterPublicKeyP *master_pub,        GNUNET_break_op (0);        return GNUNET_SYSERR;      } -    GNUNET_JSON_parse_free (spec_account);    }       /* end 'for all accounts */    return GNUNET_OK;  } diff --git a/src/lib/exchange_api_handle.c b/src/lib/exchange_api_handle.c index 601b163d..d78b6185 100644 --- a/src/lib/exchange_api_handle.c +++ b/src/lib/exchange_api_handle.c @@ -400,7 +400,7 @@ parse_json_auditor (struct TALER_EXCHANGE_AuditorInformation *auditor,                      json_t *auditor_obj,                      const struct TALER_EXCHANGE_Keys *key_data)  { -  json_t *keys; +  const json_t *keys;    json_t *key;    unsigned int len;    unsigned int off; @@ -411,8 +411,8 @@ parse_json_auditor (struct TALER_EXCHANGE_AuditorInformation *auditor,                                   &auditor->auditor_pub),      GNUNET_JSON_spec_string ("auditor_url",                               &auditor_url), -    GNUNET_JSON_spec_json ("denomination_keys", -                           &keys), +    GNUNET_JSON_spec_array_const ("denomination_keys", +                                  &keys),      GNUNET_JSON_spec_end ()    }; @@ -492,7 +492,6 @@ parse_json_auditor (struct TALER_EXCHANGE_AuditorInformation *auditor,              &auditor_sig))        {          GNUNET_break_op (0); -        GNUNET_JSON_parse_free (spec);          return GNUNET_SYSERR;        }      } @@ -501,7 +500,6 @@ parse_json_auditor (struct TALER_EXCHANGE_AuditorInformation *auditor,      off++;    }    auditor->num_denom_keys = off; -  GNUNET_JSON_parse_free (spec);    return GNUNET_OK;  } @@ -734,7 +732,7 @@ decode_keys_json (const json_t *resp_obj,    const char *currency;    const char *asset_type;    bool tipping_allowed = true; -  json_t *wblwk = NULL; +  const json_t *wblwk = NULL;    struct GNUNET_JSON_Specification mspec[] = {      GNUNET_JSON_spec_fixed_auto ("denominations_sig",                                   &denominations_sig), @@ -755,8 +753,8 @@ decode_keys_json (const json_t *resp_obj,                               &tipping_allowed),        NULL),      GNUNET_JSON_spec_mark_optional ( -      GNUNET_JSON_spec_json ("wallet_balance_limit_without_kyc", -                             &wblwk), +      GNUNET_JSON_spec_array_const ("wallet_balance_limit_without_kyc", +                                    &wblwk),        NULL),      GNUNET_JSON_spec_end ()    }; @@ -908,14 +906,14 @@ decode_keys_json (const json_t *resp_obj,    /* TODO: maybe lift all this into a FP in TALER_Extension ? */    {      struct TALER_MasterSignatureP extensions_sig = {0}; -    json_t *manifests = NULL; +    const json_t *manifests = NULL;      bool no_extensions = false;      bool no_signature = false;      struct GNUNET_JSON_Specification ext_spec[] = {        GNUNET_JSON_spec_mark_optional ( -        GNUNET_JSON_spec_json ("extensions", -                               &manifests), +        GNUNET_JSON_spec_object_const ("extensions", +                                       &manifests),          &no_extensions),        GNUNET_JSON_spec_mark_optional (          GNUNET_JSON_spec_fixed_auto ( @@ -1707,15 +1705,15 @@ static void  deserialize_data (struct TALER_EXCHANGE_Handle *exchange,                    const json_t *data)  { -  json_t *keys; +  const json_t *keys;    const char *url;    uint32_t version;    struct GNUNET_TIME_Timestamp expire;    struct GNUNET_JSON_Specification spec[] = {      GNUNET_JSON_spec_uint32 ("version",                               &version), -    GNUNET_JSON_spec_json ("keys", -                           &keys), +    GNUNET_JSON_spec_array_const ("keys", +                                  &keys),      GNUNET_JSON_spec_string ("exchange_url",                               &url),      GNUNET_JSON_spec_timestamp ("expire", @@ -1742,14 +1740,12 @@ deserialize_data (struct TALER_EXCHANGE_Handle *exchange,    }    if (0 != version)    { -    GNUNET_JSON_parse_free (spec);      return; /* unsupported version */    }    if (0 != strcmp (url,                     exchange->url))    {      GNUNET_break (0); -    GNUNET_JSON_parse_free (spec);      return;    }    memset (&key_data, @@ -1762,7 +1758,6 @@ deserialize_data (struct TALER_EXCHANGE_Handle *exchange,                          &kresp.details.ok.compat))    {      GNUNET_break (0); -    GNUNET_JSON_parse_free (spec);      return;    }    /* decode successful, initialize with the result */ @@ -1777,7 +1772,6 @@ deserialize_data (struct TALER_EXCHANGE_Handle *exchange,    /* notify application about the key information */    exchange->cert_cb (exchange->cert_cb_cls,                       &kresp); -  GNUNET_JSON_parse_free (spec);  } diff --git a/src/lib/exchange_api_kyc_check.c b/src/lib/exchange_api_kyc_check.c index d1580e76..472a7d2d 100644 --- a/src/lib/exchange_api_kyc_check.c +++ b/src/lib/exchange_api_kyc_check.c @@ -96,7 +96,7 @@ handle_kyc_check_finished (void *cls,      break;    case MHD_HTTP_OK:      { -      json_t *kyc_details; +      const json_t *kyc_details;        uint32_t status;        struct GNUNET_JSON_Specification spec[] = {          GNUNET_JSON_spec_fixed_auto ("exchange_sig", @@ -105,8 +105,8 @@ handle_kyc_check_finished (void *cls,                                       &ks.details.ok.exchange_pub),          GNUNET_JSON_spec_timestamp ("now",                                      &ks.details.ok.timestamp), -        GNUNET_JSON_spec_json ("kyc_details", -                               &kyc_details), +        GNUNET_JSON_spec_object_const ("kyc_details", +                                       &kyc_details),          GNUNET_JSON_spec_uint32 ("aml_status",                                   &status),          GNUNET_JSON_spec_end () diff --git a/src/lib/exchange_api_link.c b/src/lib/exchange_api_link.c index 3b998f23..c2b7ac0b 100644 --- a/src/lib/exchange_api_link.c +++ b/src/lib/exchange_api_link.c @@ -270,9 +270,10 @@ parse_link_ok (struct TALER_EXCHANGE_LinkHandle *lh,       whilst 'i' and 'session' track the 2d array. *///    for (session = 0; session<json_array_size (json); session++)    { -    json_t *jsona; +    const json_t *jsona;      struct GNUNET_JSON_Specification spec[] = { -      GNUNET_JSON_spec_json ("new_coins", &jsona), +      GNUNET_JSON_spec_array_const ("new_coins", +                                    &jsona),        GNUNET_JSON_spec_end ()      }; @@ -285,16 +286,8 @@ parse_link_ok (struct TALER_EXCHANGE_LinkHandle *lh,        GNUNET_break_op (0);        return GNUNET_SYSERR;      } -    if (! json_is_array (jsona)) -    { -      GNUNET_break_op (0); -      GNUNET_JSON_parse_free (spec); -      return GNUNET_SYSERR; -    } -      /* count all coins over all sessions */      num_coins += json_array_size (jsona); -    GNUNET_JSON_parse_free (spec);    }    /* Now that we know how big the 1d array is, allocate       and fill it. */ @@ -307,11 +300,11 @@ parse_link_ok (struct TALER_EXCHANGE_LinkHandle *lh,      off_coin = 0;      for (session = 0; session<json_array_size (json); session++)      { -      json_t *jsona; +      const json_t *jsona;        struct TALER_TransferPublicKeyP trans_pub;        struct GNUNET_JSON_Specification spec[] = { -        GNUNET_JSON_spec_json ("new_coins", -                               &jsona), +        GNUNET_JSON_spec_array_const ("new_coins", +                                      &jsona),          GNUNET_JSON_spec_fixed_auto ("transfer_pub",                                       &trans_pub),          GNUNET_JSON_spec_end () @@ -326,12 +319,6 @@ parse_link_ok (struct TALER_EXCHANGE_LinkHandle *lh,          GNUNET_break_op (0);          return GNUNET_SYSERR;        } -      if (! json_is_array (jsona)) -      { -        GNUNET_break_op (0); -        GNUNET_JSON_parse_free (spec); -        return GNUNET_SYSERR; -      }        /* decode all coins */        for (i = 0; i<json_array_size (jsona); i++) @@ -357,10 +344,8 @@ parse_link_ok (struct TALER_EXCHANGE_LinkHandle *lh,        {          GNUNET_break_op (0);          ret = GNUNET_SYSERR; -        GNUNET_JSON_parse_free (spec);          break;        } -      GNUNET_JSON_parse_free (spec);      } /* end of for (session) */      if (off_coin == num_coins) diff --git a/src/lib/exchange_api_lookup_aml_decision.c b/src/lib/exchange_api_lookup_aml_decision.c index 9e20c83b..01e98213 100644 --- a/src/lib/exchange_api_lookup_aml_decision.c +++ b/src/lib/exchange_api_lookup_aml_decision.c @@ -127,13 +127,12 @@ parse_kyc_attributes (const json_t *kyc_attributes,    json_array_foreach (kyc_attributes, idx, obj)    {      struct TALER_EXCHANGE_KycHistoryDetail *kyc = &kyc_attributes_ar[idx]; -    json_t *attributes = NULL;      struct GNUNET_JSON_Specification spec[] = {        GNUNET_JSON_spec_timestamp ("collection_time",                                    &kyc->collection_time),        GNUNET_JSON_spec_mark_optional ( -        GNUNET_JSON_spec_json ("attributes", -                               &attributes), +        GNUNET_JSON_spec_object_const ("attributes", +                                       &kyc->attributes),          NULL),        GNUNET_JSON_spec_string ("provider_section",                                 &kyc->provider_section), @@ -149,8 +148,6 @@ parse_kyc_attributes (const json_t *kyc_attributes,        GNUNET_break_op (0);        return GNUNET_SYSERR;      } -    kyc->attributes = attributes; -    json_decref (attributes); /* this is OK, RC preserved via 'kyc_attributes' as long as needed! */    }    return GNUNET_OK;  } @@ -171,13 +168,13 @@ parse_decision_ok (struct TALER_EXCHANGE_LookupAmlDecision *lh,      .hr.reply = json,      .hr.http_status = MHD_HTTP_OK    }; -  json_t *aml_history; -  json_t *kyc_attributes; +  const json_t *aml_history; +  const json_t *kyc_attributes;    struct GNUNET_JSON_Specification spec[] = { -    GNUNET_JSON_spec_json ("aml_history", -                           &aml_history), -    GNUNET_JSON_spec_json ("kyc_attributes", -                           &kyc_attributes), +    GNUNET_JSON_spec_array_const ("aml_history", +                                  &aml_history), +    GNUNET_JSON_spec_array_const ("kyc_attributes", +                                  &kyc_attributes),      GNUNET_JSON_spec_end ()    }; @@ -199,6 +196,12 @@ parse_decision_ok (struct TALER_EXCHANGE_LookupAmlDecision *lh,        GNUNET_NZL (lr.details.ok.kyc_attributes_length)];      enum GNUNET_GenericReturnValue ret = GNUNET_SYSERR; +    memset (aml_history_ar, +            0, +            sizeof (aml_history_ar)); +    memset (kyc_attributes_ar, +            0, +            sizeof (kyc_attributes_ar));      lr.details.ok.aml_history = aml_history_ar;      lr.details.ok.kyc_attributes = kyc_attributes_ar;      ret = parse_aml_history (aml_history, diff --git a/src/lib/exchange_api_lookup_aml_decisions.c b/src/lib/exchange_api_lookup_aml_decisions.c index 403acb54..22222b1e 100644 --- a/src/lib/exchange_api_lookup_aml_decisions.c +++ b/src/lib/exchange_api_lookup_aml_decisions.c @@ -123,10 +123,10 @@ parse_decisions_ok (struct TALER_EXCHANGE_LookupAmlDecisions *lh,      .hr.reply = json,      .hr.http_status = MHD_HTTP_OK    }; -  json_t *records; +  const json_t *records;    struct GNUNET_JSON_Specification spec[] = { -    GNUNET_JSON_spec_json ("records", -                           &records), +    GNUNET_JSON_spec_array_const ("records", +                                  &records),      GNUNET_JSON_spec_end ()    }; diff --git a/src/lib/exchange_api_management_add_partner.c b/src/lib/exchange_api_management_add_partner.c index 75fb8aa6..fec66c56 100644 --- a/src/lib/exchange_api_management_add_partner.c +++ b/src/lib/exchange_api_management_add_partner.c @@ -79,9 +79,9 @@ handle_add_partner_finished (void *cls,  {    struct TALER_EXCHANGE_ManagementAddPartner *wh = cls;    const json_t *json = response; -  struct TALER_EXCHANGE_HttpResponse hr = { -    .http_status = (unsigned int) response_code, -    .reply = json +  struct TALER_EXCHANGE_ManagementAddPartnerResponse apr = { +    .hr.http_status = (unsigned int) response_code, +    .hr.reply = json    };    wh->job = NULL; @@ -89,34 +89,34 @@ handle_add_partner_finished (void *cls,    {    case 0:      /* no reply */ -    hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE; -    hr.hint = "server offline?"; +    apr.hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE; +    apr.hr.hint = "server offline?";      break;    case MHD_HTTP_NO_CONTENT:      break;    case MHD_HTTP_FORBIDDEN: -    hr.ec = TALER_JSON_get_error_code (json); -    hr.hint = TALER_JSON_get_error_hint (json); +    apr.hr.ec = TALER_JSON_get_error_code (json); +    apr.hr.hint = TALER_JSON_get_error_hint (json);      break;    case MHD_HTTP_CONFLICT: -    hr.ec = TALER_JSON_get_error_code (json); -    hr.hint = TALER_JSON_get_error_hint (json); +    apr.hr.ec = TALER_JSON_get_error_code (json); +    apr.hr.hint = TALER_JSON_get_error_hint (json);      break;    default:      /* unexpected response code */      GNUNET_break_op (0); -    hr.ec = TALER_JSON_get_error_code (json); -    hr.hint = TALER_JSON_get_error_hint (json); +    apr.hr.ec = TALER_JSON_get_error_code (json); +    apr.hr.hint = TALER_JSON_get_error_hint (json);      GNUNET_log (GNUNET_ERROR_TYPE_ERROR,                  "Unexpected response code %u/%d for adding exchange partner\n",                  (unsigned int) response_code, -                (int) hr.ec); +                (int) apr.hr.ec);      break;    }    if (NULL != wh->cb)    {      wh->cb (wh->cb_cls, -            &hr); +            &apr);      wh->cb = NULL;    }    TALER_EXCHANGE_management_add_partner_cancel (wh); diff --git a/src/lib/exchange_api_management_auditor_disable.c b/src/lib/exchange_api_management_auditor_disable.c index b1de80f0..8bce7f74 100644 --- a/src/lib/exchange_api_management_auditor_disable.c +++ b/src/lib/exchange_api_management_auditor_disable.c @@ -81,9 +81,9 @@ handle_auditor_disable_finished (void *cls,  {    struct TALER_EXCHANGE_ManagementAuditorDisableHandle *ah = cls;    const json_t *json = response; -  struct TALER_EXCHANGE_HttpResponse hr = { -    .http_status = (unsigned int) response_code, -    .reply = json +  struct TALER_EXCHANGE_ManagementAuditorDisableResponse adr = { +    .hr.http_status = (unsigned int) response_code, +    .hr.reply = json    };    ah->job = NULL; @@ -92,32 +92,32 @@ handle_auditor_disable_finished (void *cls,    case MHD_HTTP_NO_CONTENT:      break;    case MHD_HTTP_FORBIDDEN: -    hr.ec = TALER_JSON_get_error_code (json); -    hr.hint = TALER_JSON_get_error_hint (json); +    adr.hr.ec = TALER_JSON_get_error_code (json); +    adr.hr.hint = TALER_JSON_get_error_hint (json);      break;    case MHD_HTTP_NOT_FOUND: -    hr.ec = TALER_JSON_get_error_code (json); -    hr.hint = TALER_JSON_get_error_hint (json); +    adr.hr.ec = TALER_JSON_get_error_code (json); +    adr.hr.hint = TALER_JSON_get_error_hint (json);      break;    case MHD_HTTP_CONFLICT: -    hr.ec = TALER_JSON_get_error_code (json); -    hr.hint = TALER_JSON_get_error_hint (json); +    adr.hr.ec = TALER_JSON_get_error_code (json); +    adr.hr.hint = TALER_JSON_get_error_hint (json);      break;    default:      /* unexpected response code */      GNUNET_break_op (0); -    hr.ec = TALER_JSON_get_error_code (json); -    hr.hint = TALER_JSON_get_error_hint (json); +    adr.hr.ec = TALER_JSON_get_error_code (json); +    adr.hr.hint = TALER_JSON_get_error_hint (json);      GNUNET_log (GNUNET_ERROR_TYPE_ERROR,                  "Unexpected response code %u/%d for exchange management auditor disable\n",                  (unsigned int) response_code, -                (int) hr.ec); +                (int) adr.hr.ec);      break;    }    if (NULL != ah->cb)    {      ah->cb (ah->cb_cls, -            &hr); +            &adr);      ah->cb = NULL;    }    TALER_EXCHANGE_management_disable_auditor_cancel (ah); diff --git a/src/lib/exchange_api_management_auditor_enable.c b/src/lib/exchange_api_management_auditor_enable.c index af75215e..65018577 100644 --- a/src/lib/exchange_api_management_auditor_enable.c +++ b/src/lib/exchange_api_management_auditor_enable.c @@ -82,9 +82,9 @@ handle_auditor_enable_finished (void *cls,  {    struct TALER_EXCHANGE_ManagementAuditorEnableHandle *ah = cls;    const json_t *json = response; -  struct TALER_EXCHANGE_HttpResponse hr = { -    .http_status = (unsigned int) response_code, -    .reply = json +  struct TALER_EXCHANGE_ManagementAuditorEnableResponse aer = { +    .hr.http_status = (unsigned int) response_code, +    .hr.reply = json    };    ah->job = NULL; @@ -93,28 +93,28 @@ handle_auditor_enable_finished (void *cls,    case MHD_HTTP_NO_CONTENT:      break;    case MHD_HTTP_FORBIDDEN: -    hr.ec = TALER_JSON_get_error_code (json); -    hr.hint = TALER_JSON_get_error_hint (json); +    aer.hr.ec = TALER_JSON_get_error_code (json); +    aer.hr.hint = TALER_JSON_get_error_hint (json);      break;    case MHD_HTTP_CONFLICT: -    hr.ec = TALER_JSON_get_error_code (json); -    hr.hint = TALER_JSON_get_error_hint (json); +    aer.hr.ec = TALER_JSON_get_error_code (json); +    aer.hr.hint = TALER_JSON_get_error_hint (json);      break;    default:      /* unexpected response code */      GNUNET_break_op (0); -    hr.ec = TALER_JSON_get_error_code (json); -    hr.hint = TALER_JSON_get_error_hint (json); +    aer.hr.ec = TALER_JSON_get_error_code (json); +    aer.hr.hint = TALER_JSON_get_error_hint (json);      GNUNET_log (GNUNET_ERROR_TYPE_ERROR,                  "Unexpected response code %u/%d for exchange management auditor enable\n",                  (unsigned int) response_code, -                (int) hr.ec); +                (int) aer.hr.ec);      break;    }    if (NULL != ah->cb)    {      ah->cb (ah->cb_cls, -            &hr); +            &aer);      ah->cb = NULL;    }    TALER_EXCHANGE_management_enable_auditor_cancel (ah); diff --git a/src/lib/exchange_api_management_get_keys.c b/src/lib/exchange_api_management_get_keys.c index c649f397..df14f2e7 100644 --- a/src/lib/exchange_api_management_get_keys.c +++ b/src/lib/exchange_api_management_get_keys.c @@ -85,14 +85,14 @@ handle_ok (struct TALER_EXCHANGE_ManagementGetKeysHandle *gh,    };    struct TALER_EXCHANGE_FutureKeys *fk      = &gkr.details.ok.keys; -  json_t *sk; -  json_t *dk; +  const json_t *sk; +  const json_t *dk;    bool ok;    struct GNUNET_JSON_Specification spec[] = { -    GNUNET_JSON_spec_json ("future_denoms", -                           &dk), -    GNUNET_JSON_spec_json ("future_signkeys", -                           &sk), +    GNUNET_JSON_spec_array_const ("future_denoms", +                                  &dk), +    GNUNET_JSON_spec_array_const ("future_signkeys", +                                  &sk),      GNUNET_JSON_spec_fixed_auto ("master_pub",                                   &fk->master_pub),      GNUNET_JSON_spec_fixed_auto ("denom_secmod_public_key", @@ -127,7 +127,7 @@ handle_ok (struct TALER_EXCHANGE_ManagementGetKeysHandle *gh,                                  i);      struct TALER_EXCHANGE_FutureSigningPublicKey *sign_key        = &fk->sign_keys[i]; -    struct GNUNET_JSON_Specification spec[] = { +    struct GNUNET_JSON_Specification ispec[] = {        GNUNET_JSON_spec_fixed_auto ("key",                                     &sign_key->key),        GNUNET_JSON_spec_fixed_auto ("signkey_secmod_sig", @@ -143,7 +143,7 @@ handle_ok (struct TALER_EXCHANGE_ManagementGetKeysHandle *gh,      if (GNUNET_OK !=          GNUNET_JSON_parse (j, -                           spec, +                           ispec,                             NULL, NULL))      {        GNUNET_break_op (0); @@ -276,7 +276,6 @@ handle_ok (struct TALER_EXCHANGE_ManagementGetKeysHandle *gh,          break;        }      } -    GNUNET_JSON_parse_free (spec);      if (! ok)        break;    } @@ -289,7 +288,6 @@ handle_ok (struct TALER_EXCHANGE_ManagementGetKeysHandle *gh,      TALER_denom_pub_free (&fk->denom_keys[i].key);    GNUNET_free (fk->sign_keys);    GNUNET_free (fk->denom_keys); -  GNUNET_JSON_parse_free (spec);    return (ok) ? GNUNET_OK : GNUNET_SYSERR;  } diff --git a/src/lib/exchange_api_management_post_extensions.c b/src/lib/exchange_api_management_post_extensions.c index b9721a98..99d1653d 100644 --- a/src/lib/exchange_api_management_post_extensions.c +++ b/src/lib/exchange_api_management_post_extensions.c @@ -126,7 +126,7 @@ struct TALER_EXCHANGE_ManagementPostExtensionsHandle *  TALER_EXCHANGE_management_post_extensions (    struct GNUNET_CURL_Context *ctx,    const char *url, -  struct TALER_EXCHANGE_ManagementPostExtensionsData *ped, +  const struct TALER_EXCHANGE_ManagementPostExtensionsData *ped,    TALER_EXCHANGE_ManagementPostExtensionsCallback cb,    void *cb_cls)  { @@ -151,7 +151,7 @@ TALER_EXCHANGE_management_post_extensions (    body = GNUNET_JSON_PACK (      GNUNET_JSON_pack_object_steal ("extensions", -                                   ped->extensions), +                                   (json_t *) ped->extensions),      GNUNET_JSON_pack_data_auto ("extensions_sig",                                  &ped->extensions_sig)); diff --git a/src/lib/exchange_api_management_set_global_fee.c b/src/lib/exchange_api_management_set_global_fee.c index c8fae5c1..518e710c 100644 --- a/src/lib/exchange_api_management_set_global_fee.c +++ b/src/lib/exchange_api_management_set_global_fee.c @@ -79,9 +79,9 @@ handle_set_global_fee_finished (void *cls,  {    struct TALER_EXCHANGE_ManagementSetGlobalFeeHandle *sgfh = cls;    const json_t *json = response; -  struct TALER_EXCHANGE_HttpResponse hr = { -    .http_status = (unsigned int) response_code, -    .reply = json +  struct TALER_EXCHANGE_ManagementSetGlobalFeeResponse sfr = { +    .hr.http_status = (unsigned int) response_code, +    .hr.reply = json    };    sgfh->job = NULL; @@ -90,32 +90,32 @@ handle_set_global_fee_finished (void *cls,    case MHD_HTTP_NO_CONTENT:      break;    case MHD_HTTP_FORBIDDEN: -    hr.ec = TALER_JSON_get_error_code (json); -    hr.hint = TALER_JSON_get_error_hint (json); +    sfr.hr.ec = TALER_JSON_get_error_code (json); +    sfr.hr.hint = TALER_JSON_get_error_hint (json);      break;    case MHD_HTTP_CONFLICT: -    hr.ec = TALER_JSON_get_error_code (json); -    hr.hint = TALER_JSON_get_error_hint (json); +    sfr.hr.ec = TALER_JSON_get_error_code (json); +    sfr.hr.hint = TALER_JSON_get_error_hint (json);      break;    case MHD_HTTP_PRECONDITION_FAILED: -    hr.ec = TALER_JSON_get_error_code (json); -    hr.hint = TALER_JSON_get_error_hint (json); +    sfr.hr.ec = TALER_JSON_get_error_code (json); +    sfr.hr.hint = TALER_JSON_get_error_hint (json);      break;    default:      /* unexpected response code */      GNUNET_break_op (0); -    hr.ec = TALER_JSON_get_error_code (json); -    hr.hint = TALER_JSON_get_error_hint (json); +    sfr.hr.ec = TALER_JSON_get_error_code (json); +    sfr.hr.hint = TALER_JSON_get_error_hint (json);      GNUNET_log (GNUNET_ERROR_TYPE_ERROR,                  "Unexpected response code %u/%d for exchange management set global fee\n",                  (unsigned int) response_code, -                (int) hr.ec); +                (int) sfr.hr.ec);      break;    }    if (NULL != sgfh->cb)    {      sgfh->cb (sgfh->cb_cls, -              &hr); +              &sfr);      sgfh->cb = NULL;    }    TALER_EXCHANGE_management_set_global_fees_cancel (sgfh); diff --git a/src/lib/exchange_api_management_set_wire_fee.c b/src/lib/exchange_api_management_set_wire_fee.c index 72526116..01ed7742 100644 --- a/src/lib/exchange_api_management_set_wire_fee.c +++ b/src/lib/exchange_api_management_set_wire_fee.c @@ -79,9 +79,9 @@ handle_set_wire_fee_finished (void *cls,  {    struct TALER_EXCHANGE_ManagementSetWireFeeHandle *swfh = cls;    const json_t *json = response; -  struct TALER_EXCHANGE_HttpResponse hr = { -    .http_status = (unsigned int) response_code, -    .reply = json +  struct TALER_EXCHANGE_ManagementSetWireFeeResponse swr = { +    .hr.http_status = (unsigned int) response_code, +    .hr.reply = json    };    swfh->job = NULL; @@ -90,32 +90,32 @@ handle_set_wire_fee_finished (void *cls,    case MHD_HTTP_NO_CONTENT:      break;    case MHD_HTTP_FORBIDDEN: -    hr.ec = TALER_JSON_get_error_code (json); -    hr.hint = TALER_JSON_get_error_hint (json); +    swr.hr.ec = TALER_JSON_get_error_code (json); +    swr.hr.hint = TALER_JSON_get_error_hint (json);      break;    case MHD_HTTP_CONFLICT: -    hr.ec = TALER_JSON_get_error_code (json); -    hr.hint = TALER_JSON_get_error_hint (json); +    swr.hr.ec = TALER_JSON_get_error_code (json); +    swr.hr.hint = TALER_JSON_get_error_hint (json);      break;    case MHD_HTTP_PRECONDITION_FAILED: -    hr.ec = TALER_JSON_get_error_code (json); -    hr.hint = TALER_JSON_get_error_hint (json); +    swr.hr.ec = TALER_JSON_get_error_code (json); +    swr.hr.hint = TALER_JSON_get_error_hint (json);      break;    default:      /* unexpected response code */      GNUNET_break_op (0); -    hr.ec = TALER_JSON_get_error_code (json); -    hr.hint = TALER_JSON_get_error_hint (json); +    swr.hr.ec = TALER_JSON_get_error_code (json); +    swr.hr.hint = TALER_JSON_get_error_hint (json);      GNUNET_log (GNUNET_ERROR_TYPE_ERROR,                  "Unexpected response code %u/%d for exchange management set wire fee\n",                  (unsigned int) response_code, -                (int) hr.ec); +                (int) swr.hr.ec);      break;    }    if (NULL != swfh->cb)    {      swfh->cb (swfh->cb_cls, -              &hr); +              &swr);      swfh->cb = NULL;    }    TALER_EXCHANGE_management_set_wire_fees_cancel (swfh); diff --git a/src/lib/exchange_api_refreshes_reveal.c b/src/lib/exchange_api_refreshes_reveal.c index 3bdef202..50de7681 100644 --- a/src/lib/exchange_api_refreshes_reveal.c +++ b/src/lib/exchange_api_refreshes_reveal.c @@ -107,10 +107,10 @@ refresh_reveal_ok (struct TALER_EXCHANGE_RefreshesRevealHandle *rrh,                     const json_t *json,                     struct TALER_EXCHANGE_RevealedCoinInfo *rcis)  { -  json_t *jsona; +  const json_t *jsona;    struct GNUNET_JSON_Specification outer_spec[] = { -    GNUNET_JSON_spec_json ("ev_sigs", -                           &jsona), +    GNUNET_JSON_spec_array_const ("ev_sigs", +                                  &jsona),      GNUNET_JSON_spec_end ()    }; @@ -122,18 +122,10 @@ refresh_reveal_ok (struct TALER_EXCHANGE_RefreshesRevealHandle *rrh,      GNUNET_break_op (0);      return GNUNET_SYSERR;    } -  if (! json_is_array (jsona)) -  { -    /* We expected an array of coins */ -    GNUNET_break_op (0); -    GNUNET_JSON_parse_free (outer_spec); -    return GNUNET_SYSERR; -  }    if (rrh->md.num_fresh_coins != json_array_size (jsona))    {      /* Number of coins generated does not match our expectation */      GNUNET_break_op (0); -    GNUNET_JSON_parse_free (outer_spec);      return GNUNET_SYSERR;    }    for (unsigned int i = 0; i<rrh->md.num_fresh_coins; i++) @@ -180,7 +172,6 @@ refresh_reveal_ok (struct TALER_EXCHANGE_RefreshesRevealHandle *rrh,                             NULL, NULL))      {        GNUNET_break_op (0); -      GNUNET_JSON_parse_free (outer_spec);        return GNUNET_SYSERR;      } @@ -209,13 +200,11 @@ refresh_reveal_ok (struct TALER_EXCHANGE_RefreshesRevealHandle *rrh,      {        GNUNET_break_op (0);        GNUNET_JSON_parse_free (spec); -      GNUNET_JSON_parse_free (outer_spec);        return GNUNET_SYSERR;      }      GNUNET_JSON_parse_free (spec);      rci->sig = coin.sig;    } -  GNUNET_JSON_parse_free (outer_spec);    return GNUNET_OK;  } diff --git a/src/lib/exchange_api_refund.c b/src/lib/exchange_api_refund.c index 7c9616ea..35524ca4 100644 --- a/src/lib/exchange_api_refund.c +++ b/src/lib/exchange_api_refund.c @@ -172,11 +172,11 @@ static enum GNUNET_GenericReturnValue  verify_conflict_history_ok (struct TALER_EXCHANGE_RefundHandle *rh,                              const json_t *json)  { -  json_t *history; +  const json_t *history;    struct TALER_DenominationHashP h_denom_pub;    struct GNUNET_JSON_Specification spec[] = { -    GNUNET_JSON_spec_json ("history", -                           &history), +    GNUNET_JSON_spec_array_const ("history", +                                  &history),      GNUNET_JSON_spec_fixed_auto ("h_denom_pub",                                   &h_denom_pub),      GNUNET_JSON_spec_end () @@ -199,7 +199,6 @@ verify_conflict_history_ok (struct TALER_EXCHANGE_RefundHandle *rh,    if (0 == len)    {      GNUNET_break_op (0); -    GNUNET_JSON_parse_free (spec);      return GNUNET_SYSERR;    }    have_deposit = false; @@ -225,7 +224,6 @@ verify_conflict_history_ok (struct TALER_EXCHANGE_RefundHandle *rh,                             NULL, NULL))      {        GNUNET_break_op (0); -      GNUNET_JSON_parse_free (spec);        return GNUNET_SYSERR;      }      if (0 == strcasecmp (type, @@ -274,7 +272,6 @@ verify_conflict_history_ok (struct TALER_EXCHANGE_RefundHandle *rh,                               NULL, NULL))        {          GNUNET_break_op (0); -        GNUNET_JSON_parse_free (spec);          return GNUNET_SYSERR;        }        if (GNUNET_OK != @@ -292,7 +289,6 @@ verify_conflict_history_ok (struct TALER_EXCHANGE_RefundHandle *rh,                                         &sig))        {          GNUNET_break_op (0); -        GNUNET_JSON_parse_free (spec);          return GNUNET_SYSERR;        }        if ( (0 != GNUNET_memcmp (&rh->h_contract_terms, @@ -302,7 +298,6 @@ verify_conflict_history_ok (struct TALER_EXCHANGE_RefundHandle *rh,        {          /* deposit information is about a different merchant/contract */          GNUNET_break_op (0); -        GNUNET_JSON_parse_free (spec);          return GNUNET_SYSERR;        }        if (have_deposit) @@ -313,7 +308,6 @@ verify_conflict_history_ok (struct TALER_EXCHANGE_RefundHandle *rh,                                         &dtotal))          {            GNUNET_break_op (0); -          GNUNET_JSON_parse_free (spec);            return GNUNET_SYSERR;          }          GNUNET_break (0 <= @@ -356,7 +350,6 @@ verify_conflict_history_ok (struct TALER_EXCHANGE_RefundHandle *rh,                               NULL, NULL))        {          GNUNET_break_op (0); -        GNUNET_JSON_parse_free (spec);          return GNUNET_SYSERR;        }        if (0 > @@ -365,7 +358,6 @@ verify_conflict_history_ok (struct TALER_EXCHANGE_RefundHandle *rh,                              &amount))        {          GNUNET_break_op (0); -        GNUNET_JSON_parse_free (spec);          return GNUNET_SYSERR;        }        if (GNUNET_OK != @@ -377,7 +369,6 @@ verify_conflict_history_ok (struct TALER_EXCHANGE_RefundHandle *rh,                                          &sig))        {          GNUNET_break_op (0); -        GNUNET_JSON_parse_free (spec);          return GNUNET_SYSERR;        }        if ( (0 != GNUNET_memcmp (&rh->h_contract_terms, @@ -387,7 +378,6 @@ verify_conflict_history_ok (struct TALER_EXCHANGE_RefundHandle *rh,        {          /* refund is about a different merchant/contract */          GNUNET_break_op (0); -        GNUNET_JSON_parse_free (spec);          return GNUNET_SYSERR;        }        if (rtransaction_id == rh->rtransaction_id) @@ -395,7 +385,6 @@ verify_conflict_history_ok (struct TALER_EXCHANGE_RefundHandle *rh,          /* Eh, this shows either a dependency failure or idempotency,             but must not happen in a conflict reply. Fail! */          GNUNET_break_op (0); -        GNUNET_JSON_parse_free (spec);          return GNUNET_SYSERR;        } @@ -406,7 +395,6 @@ verify_conflict_history_ok (struct TALER_EXCHANGE_RefundHandle *rh,                                         &rtotal))          {            GNUNET_break_op (0); -          GNUNET_JSON_parse_free (spec);            return GNUNET_SYSERR;          }          GNUNET_break (0 <= @@ -427,7 +415,6 @@ verify_conflict_history_ok (struct TALER_EXCHANGE_RefundHandle *rh,                    "Unexpected type `%s' in response for exchange refund\n",                    type);        GNUNET_break_op (0); -      GNUNET_JSON_parse_free (spec);        return GNUNET_SYSERR;      }    } @@ -440,7 +427,6 @@ verify_conflict_history_ok (struct TALER_EXCHANGE_RefundHandle *rh,                            &rh->refund_amount))      {        GNUNET_break (0); -      GNUNET_JSON_parse_free (spec);        return GNUNET_SYSERR;      }    } @@ -452,7 +438,6 @@ verify_conflict_history_ok (struct TALER_EXCHANGE_RefundHandle *rh,    if (! have_deposit)    {      GNUNET_break (0); -    GNUNET_JSON_parse_free (spec);      return GNUNET_SYSERR;    }    if (-1 != TALER_amount_cmp (&dtotal, @@ -460,11 +445,9 @@ verify_conflict_history_ok (struct TALER_EXCHANGE_RefundHandle *rh,    {      /* rtotal <= dtotal is fine, no conflict! */      GNUNET_break_op (0); -    GNUNET_JSON_parse_free (spec);      return GNUNET_SYSERR;    }    /* dtotal < rtotal: that's a conflict! */ -  GNUNET_JSON_parse_free (spec);    return GNUNET_OK;  } @@ -482,11 +465,11 @@ static enum GNUNET_GenericReturnValue  verify_failed_dependency_ok (struct TALER_EXCHANGE_RefundHandle *rh,                               const json_t *json)  { -  json_t *h; +  const json_t *h;    json_t *e;    struct GNUNET_JSON_Specification spec[] = { -    GNUNET_JSON_spec_json ("history", -                           &h), +    GNUNET_JSON_spec_array_const ("history", +                                  &h),      GNUNET_JSON_spec_end ()    }; @@ -498,11 +481,9 @@ verify_failed_dependency_ok (struct TALER_EXCHANGE_RefundHandle *rh,      GNUNET_break_op (0);      return GNUNET_SYSERR;    } -  if ( (! json_is_array (h)) || -       (1 != json_array_size (h) ) ) +  if (1 != json_array_size (h))    {      GNUNET_break_op (0); -    GNUNET_JSON_parse_free (spec);      return GNUNET_SYSERR;    }    e = json_array_get (h, 0); @@ -538,7 +519,6 @@ verify_failed_dependency_ok (struct TALER_EXCHANGE_RefundHandle *rh,                             NULL, NULL))      {        GNUNET_break_op (0); -      GNUNET_JSON_parse_free (spec);        return GNUNET_SYSERR;      }      if (GNUNET_OK != @@ -550,7 +530,6 @@ verify_failed_dependency_ok (struct TALER_EXCHANGE_RefundHandle *rh,                                        &sig))      {        GNUNET_break_op (0); -      GNUNET_JSON_parse_free (spec);        return GNUNET_SYSERR;      }      if ( (rtransaction_id != rh->rtransaction_id) || @@ -562,11 +541,9 @@ verify_failed_dependency_ok (struct TALER_EXCHANGE_RefundHandle *rh,                                   &amount)) )      {        GNUNET_break_op (0); -      GNUNET_JSON_parse_free (spec);        return GNUNET_SYSERR;      }    } -  GNUNET_JSON_parse_free (spec);    return GNUNET_OK;  } diff --git a/src/lib/exchange_api_reserves_attest.c b/src/lib/exchange_api_reserves_attest.c index 0a9134e8..82d5785b 100644 --- a/src/lib/exchange_api_reserves_attest.c +++ b/src/lib/exchange_api_reserves_attest.c @@ -93,7 +93,7 @@ handle_reserves_attest_ok (struct TALER_EXCHANGE_ReservesAttestHandle *rsh,      .hr.reply = j,      .hr.http_status = MHD_HTTP_OK    }; -  json_t *attributes; +  const json_t *attributes;    struct GNUNET_JSON_Specification spec[] = {      GNUNET_JSON_spec_timestamp ("exchange_timestamp",                                  &rs.details.ok.exchange_time), @@ -103,8 +103,8 @@ handle_reserves_attest_ok (struct TALER_EXCHANGE_ReservesAttestHandle *rsh,                                   &rs.details.ok.exchange_sig),      GNUNET_JSON_spec_fixed_auto ("exchange_pub",                                   &rs.details.ok.exchange_pub), -    GNUNET_JSON_spec_json ("attributes", -                           &attributes), +    GNUNET_JSON_spec_object_const ("attributes", +                                   &attributes),      GNUNET_JSON_spec_end ()    }; diff --git a/src/lib/exchange_api_reserves_get_attestable.c b/src/lib/exchange_api_reserves_get_attestable.c index 3a5fd25d..b272d478 100644 --- a/src/lib/exchange_api_reserves_get_attestable.c +++ b/src/lib/exchange_api_reserves_get_attestable.c @@ -88,10 +88,10 @@ handle_reserves_get_attestable_ok (      .hr.reply = j,      .hr.http_status = MHD_HTTP_OK    }; -  json_t *details; +  const json_t *details;    struct GNUNET_JSON_Specification spec[] = { -    GNUNET_JSON_spec_json ("details", -                           &details), +    GNUNET_JSON_spec_array_const ("details", +                                  &details),      GNUNET_JSON_spec_end ()    }; @@ -116,7 +116,6 @@ handle_reserves_get_attestable_ok (        if (NULL == attributes[i])        {          GNUNET_break_op (0); -        GNUNET_JSON_parse_free (spec);          return GNUNET_SYSERR;        }      } @@ -126,7 +125,6 @@ handle_reserves_get_attestable_ok (                &rs);      rgah->cb = NULL;    } -  GNUNET_JSON_parse_free (spec);    return GNUNET_OK;  } diff --git a/src/lib/exchange_api_reserves_history.c b/src/lib/exchange_api_reserves_history.c index 2a0dd565..ccc11a27 100644 --- a/src/lib/exchange_api_reserves_history.c +++ b/src/lib/exchange_api_reserves_history.c @@ -99,7 +99,7 @@ static enum GNUNET_GenericReturnValue  handle_reserves_history_ok (struct TALER_EXCHANGE_ReservesHistoryHandle *rsh,                              const json_t *j)  { -  json_t *history; +  const json_t *history;    unsigned int len;    struct TALER_EXCHANGE_ReserveHistory rs = {      .hr.reply = j, @@ -110,8 +110,8 @@ handle_reserves_history_ok (struct TALER_EXCHANGE_ReservesHistoryHandle *rsh,    struct GNUNET_JSON_Specification spec[] = {      TALER_JSON_spec_amount_any ("balance",                                  &rs.details.ok.balance), -    GNUNET_JSON_spec_json ("history", -                           &history), +    GNUNET_JSON_spec_array_const ("history", +                                  &history),      GNUNET_JSON_spec_end ()    }; @@ -143,7 +143,6 @@ handle_reserves_history_ok (struct TALER_EXCHANGE_ReservesHistoryHandle *rsh,        GNUNET_break_op (0);        TALER_EXCHANGE_free_reserve_history (rhistory,                                             len); -      GNUNET_JSON_parse_free (spec);        return GNUNET_SYSERR;      }      if (NULL != rsh->cb) @@ -157,7 +156,6 @@ handle_reserves_history_ok (struct TALER_EXCHANGE_ReservesHistoryHandle *rsh,      TALER_EXCHANGE_free_reserve_history (rhistory,                                           len);    } -  GNUNET_JSON_parse_free (spec);    return GNUNET_OK;  } diff --git a/src/lib/exchange_api_reserves_status.c b/src/lib/exchange_api_reserves_status.c index 27f63d24..57fb0427 100644 --- a/src/lib/exchange_api_reserves_status.c +++ b/src/lib/exchange_api_reserves_status.c @@ -89,7 +89,7 @@ static enum GNUNET_GenericReturnValue  handle_reserves_status_ok (struct TALER_EXCHANGE_ReservesStatusHandle *rsh,                             const json_t *j)  { -  json_t *history; +  const json_t *history;    unsigned int len;    struct TALER_EXCHANGE_ReserveStatus rs = {      .hr.reply = j, @@ -98,8 +98,8 @@ handle_reserves_status_ok (struct TALER_EXCHANGE_ReservesStatusHandle *rsh,    struct GNUNET_JSON_Specification spec[] = {      TALER_JSON_spec_amount_any ("balance",                                  &rs.details.ok.balance), -    GNUNET_JSON_spec_json ("history", -                           &history), +    GNUNET_JSON_spec_array_const ("history", +                                  &history),      GNUNET_JSON_spec_end ()    }; @@ -145,7 +145,6 @@ handle_reserves_status_ok (struct TALER_EXCHANGE_ReservesStatusHandle *rsh,      TALER_EXCHANGE_free_reserve_history (rhistory,                                           len);    } -  GNUNET_JSON_parse_free (spec);    return GNUNET_OK;  } diff --git a/src/lib/exchange_api_transfers_get.c b/src/lib/exchange_api_transfers_get.c index f00e36ce..3a5a64fd 100644 --- a/src/lib/exchange_api_transfers_get.c +++ b/src/lib/exchange_api_transfers_get.c @@ -84,7 +84,7 @@ check_transfers_get_response_ok (    struct TALER_EXCHANGE_TransfersGetHandle *wdh,    const json_t *json)  { -  json_t *details_j; +  const json_t *details_j;    struct TALER_Amount total_expected;    struct TALER_MerchantPublicKeyP merchant_pub;    struct TALER_EXCHANGE_TransfersGetResponse tgr = { @@ -104,8 +104,8 @@ check_transfers_get_response_ok (                                   &td->h_payto),      GNUNET_JSON_spec_timestamp ("execution_time",                                  &td->execution_time), -    GNUNET_JSON_spec_json ("deposits", -                           &details_j), +    GNUNET_JSON_spec_array_const ("deposits", +                                  &details_j),      GNUNET_JSON_spec_fixed_auto ("exchange_sig",                                   &td->exchange_sig),      GNUNET_JSON_spec_fixed_auto ("exchange_pub", @@ -126,7 +126,6 @@ check_transfers_get_response_ok (                               &total_expected))    {      GNUNET_break_op (0); -    GNUNET_JSON_parse_free (spec);      return GNUNET_SYSERR;    }    if (GNUNET_OK != @@ -135,7 +134,6 @@ check_transfers_get_response_ok (          &td->exchange_pub))    {      GNUNET_break_op (0); -    GNUNET_JSON_parse_free (spec);      return GNUNET_SYSERR;    }    td->details_length = json_array_size (details_j); @@ -181,7 +179,6 @@ check_transfers_get_response_ok (        {          GNUNET_break_op (0);          GNUNET_CRYPTO_hash_context_abort (hash_context); -        GNUNET_JSON_parse_free (spec);          GNUNET_free (details);          return GNUNET_SYSERR;        } @@ -211,7 +208,6 @@ check_transfers_get_response_ok (              &td->exchange_sig))        {          GNUNET_break_op (0); -        GNUNET_JSON_parse_free (spec);          GNUNET_free (details);          return GNUNET_SYSERR;        } @@ -223,7 +219,6 @@ check_transfers_get_response_ok (                                 &td->wire_fee))      {        GNUNET_break_op (0); -      GNUNET_JSON_parse_free (spec);        GNUNET_free (details);        return GNUNET_SYSERR;      } @@ -232,7 +227,6 @@ check_transfers_get_response_ok (                            &td->total_amount))      {        GNUNET_break_op (0); -      GNUNET_JSON_parse_free (spec);        GNUNET_free (details);        return GNUNET_SYSERR;      } @@ -240,7 +234,6 @@ check_transfers_get_response_ok (               &tgr);      GNUNET_free (details);    } -  GNUNET_JSON_parse_free (spec);    return GNUNET_OK;  } | 
