summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2016-10-20 21:19:01 +0200
committerChristian Grothoff <christian@grothoff.org>2016-10-20 21:19:01 +0200
commit19f4c50dabd6a4c29749a9c758e7e0da99d9e31f (patch)
tree559cbffee16240be807eeba641dbcf695891609d /src
parent63c5706b64a5fe2989514c5f18e2926b91e420de (diff)
downloadexchange-19f4c50dabd6a4c29749a9c758e7e0da99d9e31f.tar.gz
exchange-19f4c50dabd6a4c29749a9c758e7e0da99d9e31f.tar.bz2
exchange-19f4c50dabd6a4c29749a9c758e7e0da99d9e31f.zip
rename and move TALER_EXCHANGE_json_get_error_code to TALER_JSON_get_error_code
Diffstat (limited to 'src')
-rw-r--r--src/exchange-lib/exchange_api_admin.c2
-rw-r--r--src/exchange-lib/exchange_api_common.c27
-rw-r--r--src/exchange-lib/exchange_api_deposit.c2
-rw-r--r--src/exchange-lib/exchange_api_refresh.c6
-rw-r--r--src/exchange-lib/exchange_api_refresh_link.c2
-rw-r--r--src/exchange-lib/exchange_api_refund.c2
-rw-r--r--src/exchange-lib/exchange_api_reserve.c4
-rw-r--r--src/exchange-lib/exchange_api_track_transaction.c2
-rw-r--r--src/exchange-lib/exchange_api_track_transfer.c2
-rw-r--r--src/exchange-lib/exchange_api_wire.c2
-rw-r--r--src/include/taler_exchange_service.h11
-rw-r--r--src/include/taler_json_lib.h12
-rw-r--r--src/include/taler_util.h2
-rw-r--r--src/json/json.c29
14 files changed, 55 insertions, 50 deletions
diff --git a/src/exchange-lib/exchange_api_admin.c b/src/exchange-lib/exchange_api_admin.c
index d50afdc6b..e6cb8101c 100644
--- a/src/exchange-lib/exchange_api_admin.c
+++ b/src/exchange-lib/exchange_api_admin.c
@@ -129,7 +129,7 @@ handle_admin_add_incoming_finished (void *cls,
}
aai->cb (aai->cb_cls,
response_code,
- TALER_EXCHANGE_json_get_error_code (json),
+ TALER_JSON_get_error_code (json),
json);
TALER_EXCHANGE_admin_add_incoming_cancel (aai);
}
diff --git a/src/exchange-lib/exchange_api_common.c b/src/exchange-lib/exchange_api_common.c
index bd45619d8..a531b1c39 100644
--- a/src/exchange-lib/exchange_api_common.c
+++ b/src/exchange-lib/exchange_api_common.c
@@ -27,33 +27,6 @@
/**
- * Extract the Taler error code from the given @a json object.
- * Note that #TALER_EC_NONE is returned if no "code" is present.
- *
- * @param json response to extract the error code from
- * @return the "code" value from @a json
- */
-enum TALER_ErrorCode
-TALER_EXCHANGE_json_get_error_code (const json_t *json)
-{
- const json_t *jc;
-
- if (NULL == json)
- {
- GNUNET_break_op (0);
- return TALER_EC_INVALID_RESPONSE;
- }
- jc = json_object_get (json, "code");
- if (NULL == jc)
- return TALER_EC_NONE;
- if (json_is_integer (jc))
- return (enum TALER_ErrorCode) json_integer_value (jc);
- GNUNET_break_op (0);
- return TALER_EC_INVALID;
-}
-
-
-/**
* Verify a coins transaction history as returned by the exchange.
*
* @param currency expected currency for the coin
diff --git a/src/exchange-lib/exchange_api_deposit.c b/src/exchange-lib/exchange_api_deposit.c
index 416f4419c..9282bbfd1 100644
--- a/src/exchange-lib/exchange_api_deposit.c
+++ b/src/exchange-lib/exchange_api_deposit.c
@@ -261,7 +261,7 @@ handle_deposit_finished (void *cls,
}
dh->cb (dh->cb_cls,
response_code,
- TALER_EXCHANGE_json_get_error_code (json),
+ TALER_JSON_get_error_code (json),
ep,
json);
TALER_EXCHANGE_deposit_cancel (dh);
diff --git a/src/exchange-lib/exchange_api_refresh.c b/src/exchange-lib/exchange_api_refresh.c
index 556a53c48..c3216a6e6 100644
--- a/src/exchange-lib/exchange_api_refresh.c
+++ b/src/exchange-lib/exchange_api_refresh.c
@@ -1114,7 +1114,7 @@ handle_refresh_melt_finished (void *cls,
{
rmh->melt_cb (rmh->melt_cb_cls,
response_code,
- TALER_EXCHANGE_json_get_error_code (json),
+ TALER_JSON_get_error_code (json),
noreveal_index,
(0 == response_code) ? NULL : &exchange_pub,
json);
@@ -1160,7 +1160,7 @@ handle_refresh_melt_finished (void *cls,
if (NULL != rmh->melt_cb)
rmh->melt_cb (rmh->melt_cb_cls,
response_code,
- TALER_EXCHANGE_json_get_error_code (json),
+ TALER_JSON_get_error_code (json),
UINT16_MAX,
NULL,
json);
@@ -1636,7 +1636,7 @@ handle_refresh_reveal_finished (void *cls,
if (NULL != rrh->reveal_cb)
rrh->reveal_cb (rrh->reveal_cb_cls,
response_code,
- TALER_EXCHANGE_json_get_error_code (json),
+ TALER_JSON_get_error_code (json),
0,
NULL,
NULL,
diff --git a/src/exchange-lib/exchange_api_refresh_link.c b/src/exchange-lib/exchange_api_refresh_link.c
index 32f3f2ad5..9b825138e 100644
--- a/src/exchange-lib/exchange_api_refresh_link.c
+++ b/src/exchange-lib/exchange_api_refresh_link.c
@@ -346,7 +346,7 @@ handle_refresh_link_finished (void *cls,
if (NULL != rlh->link_cb)
rlh->link_cb (rlh->link_cb_cls,
response_code,
- TALER_EXCHANGE_json_get_error_code (json),
+ TALER_JSON_get_error_code (json),
0,
NULL,
NULL,
diff --git a/src/exchange-lib/exchange_api_refund.c b/src/exchange-lib/exchange_api_refund.c
index 0d5656e1f..be080c57b 100644
--- a/src/exchange-lib/exchange_api_refund.c
+++ b/src/exchange-lib/exchange_api_refund.c
@@ -195,7 +195,7 @@ handle_refund_finished (void *cls,
}
rh->cb (rh->cb_cls,
response_code,
- TALER_EXCHANGE_json_get_error_code (json),
+ TALER_JSON_get_error_code (json),
ep,
json);
TALER_EXCHANGE_refund_cancel (rh);
diff --git a/src/exchange-lib/exchange_api_reserve.c b/src/exchange-lib/exchange_api_reserve.c
index bbba4f2b0..28f329c42 100644
--- a/src/exchange-lib/exchange_api_reserve.c
+++ b/src/exchange-lib/exchange_api_reserve.c
@@ -389,7 +389,7 @@ handle_reserve_status_finished (void *cls,
if (NULL != wsh->cb)
wsh->cb (wsh->cb_cls,
response_code,
- TALER_EXCHANGE_json_get_error_code (json),
+ TALER_JSON_get_error_code (json),
json,
NULL,
0, NULL);
@@ -766,7 +766,7 @@ handle_reserve_withdraw_finished (void *cls,
if (NULL != wsh->cb)
wsh->cb (wsh->cb_cls,
response_code,
- TALER_EXCHANGE_json_get_error_code (json),
+ TALER_JSON_get_error_code (json),
NULL,
json);
TALER_EXCHANGE_reserve_withdraw_cancel (wsh);
diff --git a/src/exchange-lib/exchange_api_track_transaction.c b/src/exchange-lib/exchange_api_track_transaction.c
index 50e10c446..7fd2efb21 100644
--- a/src/exchange-lib/exchange_api_track_transaction.c
+++ b/src/exchange-lib/exchange_api_track_transaction.c
@@ -238,7 +238,7 @@ handle_deposit_wtid_finished (void *cls,
}
dwh->cb (dwh->cb_cls,
response_code,
- TALER_EXCHANGE_json_get_error_code (json),
+ TALER_JSON_get_error_code (json),
ep,
json,
wtid,
diff --git a/src/exchange-lib/exchange_api_track_transfer.c b/src/exchange-lib/exchange_api_track_transfer.c
index c4ad3fd20..8ed5865d7 100644
--- a/src/exchange-lib/exchange_api_track_transfer.c
+++ b/src/exchange-lib/exchange_api_track_transfer.c
@@ -253,7 +253,7 @@ handle_track_transfer_finished (void *cls,
}
wdh->cb (wdh->cb_cls,
response_code,
- TALER_EXCHANGE_json_get_error_code (json),
+ TALER_JSON_get_error_code (json),
NULL,
json,
NULL,
diff --git a/src/exchange-lib/exchange_api_wire.c b/src/exchange-lib/exchange_api_wire.c
index 71a717d4e..7401e66d4 100644
--- a/src/exchange-lib/exchange_api_wire.c
+++ b/src/exchange-lib/exchange_api_wire.c
@@ -209,7 +209,7 @@ handle_wire_finished (void *cls,
}
wh->cb (wh->cb_cls,
response_code,
- TALER_EXCHANGE_json_get_error_code (json),
+ TALER_JSON_get_error_code (json),
(NULL != keep) ? keep : json);
if (NULL != keep)
json_decref (keep);
diff --git a/src/include/taler_exchange_service.h b/src/include/taler_exchange_service.h
index 1629ddcfa..e368f954c 100644
--- a/src/include/taler_exchange_service.h
+++ b/src/include/taler_exchange_service.h
@@ -1263,15 +1263,4 @@ TALER_EXCHANGE_verify_coin_history (const char *currency,
struct TALER_Amount *total);
-/**
- * Extract the Taler error code from the given @a json object.
- * Note that #TALER_EC_NONE is returned if no "code" is present.
- *
- * @param json response to extract the error code from
- * @return the "code" value from @a json
- */
-enum TALER_ErrorCode
-TALER_EXCHANGE_json_get_error_code (const json_t *json);
-
-
#endif /* _TALER_EXCHANGE_SERVICE_H */
diff --git a/src/include/taler_json_lib.h b/src/include/taler_json_lib.h
index b47aea5b6..b247ba1f5 100644
--- a/src/include/taler_json_lib.h
+++ b/src/include/taler_json_lib.h
@@ -25,6 +25,7 @@
#include <jansson.h>
#include <gnunet/gnunet_json_lib.h>
#include "taler_util.h"
+#include "taler_error_codes.h"
/**
* Print JSON parsing related error information
@@ -92,6 +93,17 @@ int
TALER_JSON_hash (const json_t *json,
struct GNUNET_HashCode *hc);
+/**
+ * Extract the Taler error code from the given @a json object.
+ * Note that #TALER_EC_NONE is returned if no "code" is present.
+ *
+ * @param json response to extract the error code from
+ * @return the "code" value from @a json
+ */
+enum TALER_ErrorCode
+TALER_JSON_get_error_code (const json_t *json);
+
+
#endif /* TALER_JSON_LIB_H_ */
/* End of taler_json_lib.h */
diff --git a/src/include/taler_util.h b/src/include/taler_util.h
index 613f860cd..c115594f5 100644
--- a/src/include/taler_util.h
+++ b/src/include/taler_util.h
@@ -117,4 +117,6 @@ const struct GNUNET_OS_ProjectData *
TALER_project_data_default (void);
+
+
#endif
diff --git a/src/json/json.c b/src/json/json.c
index 8f21447ec..74559e6c5 100644
--- a/src/json/json.c
+++ b/src/json/json.c
@@ -50,4 +50,33 @@ TALER_JSON_hash (const json_t *json,
}
+
+/**
+ * Extract the Taler error code from the given @a json object.
+ * Note that #TALER_EC_NONE is returned if no "code" is present.
+ *
+ * @param json response to extract the error code from
+ * @return the "code" value from @a json
+ */
+enum TALER_ErrorCode
+TALER_JSON_get_error_code (const json_t *json)
+{
+ const json_t *jc;
+
+ if (NULL == json)
+ {
+ GNUNET_break_op (0);
+ return TALER_EC_INVALID_RESPONSE;
+ }
+ jc = json_object_get (json, "code");
+ if (NULL == jc)
+ return TALER_EC_NONE;
+ if (json_is_integer (jc))
+ return (enum TALER_ErrorCode) json_integer_value (jc);
+ GNUNET_break_op (0);
+ return TALER_EC_INVALID;
+}
+
+
+
/* End of json/json.c */