summaryrefslogtreecommitdiff
path: root/src/pq
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2016-03-19 15:23:11 +0100
committerChristian Grothoff <christian@grothoff.org>2016-03-19 15:23:11 +0100
commit0d1eced630f4ed05ad95fdbb4354fd428c9cdbf6 (patch)
tree0ed4d6f189ed72287a0e003446c87a2b6db70c1a /src/pq
parentd229f78da3b0b7f851d3541f59651b4f600c879d (diff)
downloadexchange-0d1eced630f4ed05ad95fdbb4354fd428c9cdbf6.tar.gz
exchange-0d1eced630f4ed05ad95fdbb4354fd428c9cdbf6.tar.bz2
exchange-0d1eced630f4ed05ad95fdbb4354fd428c9cdbf6.zip
first refactoring of JSON logic to address #4150 and #4237
Diffstat (limited to 'src/pq')
-rw-r--r--src/pq/pq_result_helper.c25
1 files changed, 13 insertions, 12 deletions
diff --git a/src/pq/pq_result_helper.c b/src/pq/pq_result_helper.c
index 748ce0c2..49d0668a 100644
--- a/src/pq/pq_result_helper.c
+++ b/src/pq/pq_result_helper.c
@@ -72,7 +72,7 @@ extract_amount_nbo_helper (PGresult *result,
frac_name);
curr_num = PQfnumber (result,
curr_name);
- if (val_num < 0)
+ if (val_num < 0)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Field `%s' does not exist in result\n",
@@ -140,7 +140,7 @@ extract_amount_nbo_helper (PGresult *result,
* #GNUNET_YES if all results could be extracted
* #GNUNET_NO if at least one result was NULL
* #GNUNET_SYSERR if a result was invalid (non-existing field)
- */
+ */
static int
extract_amount_nbo (void *cls,
PGresult *result,
@@ -153,7 +153,7 @@ extract_amount_nbo (void *cls,
char *frac_name;
char *curr_name;
int ret;
-
+
GNUNET_asprintf (&val_name,
"%s_val",
fname);
@@ -189,7 +189,7 @@ TALER_PQ_result_spec_amount_nbo (const char *name,
{
struct GNUNET_PQ_ResultSpec res =
{ &extract_amount_nbo, NULL, NULL,
- (void *) amount, sizeof (*amount),
+ (void *) amount, sizeof (*amount),
name, NULL };
return res;
}
@@ -208,7 +208,7 @@ TALER_PQ_result_spec_amount_nbo (const char *name,
* #GNUNET_YES if all results could be extracted
* #GNUNET_NO if at least one result was NULL
* #GNUNET_SYSERR if a result was invalid (non-existing field)
- */
+ */
static int
extract_amount (void *cls,
PGresult *result,
@@ -223,7 +223,7 @@ extract_amount (void *cls,
char *curr_name;
struct TALER_AmountNBO amount_nbo;
int ret;
-
+
GNUNET_asprintf (&val_name,
"%s_val",
fname);
@@ -280,7 +280,7 @@ TALER_PQ_result_spec_amount (const char *name,
* #GNUNET_YES if all results could be extracted
* #GNUNET_NO if at least one result was NULL
* #GNUNET_SYSERR if a result was invalid (non-existing field)
- */
+ */
static int
extract_json (void *cls,
PGresult *result,
@@ -294,7 +294,7 @@ extract_json (void *cls,
int fnum;
json_error_t json_error;
size_t slen;
-
+
fnum = PQfnumber (result,
fname);
if (fnum < 0)
@@ -320,10 +320,11 @@ extract_json (void *cls,
&json_error);
if (NULL == *j_dst)
{
- TALER_json_warn (json_error);
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Failed to parse JSON result for field `%s'\n",
- fname);
+ "Failed to parse JSON result for field `%s': %s (%s)\n",
+ fname,
+ json_error.text,
+ json_error.source);
return GNUNET_SYSERR;
}
return GNUNET_OK;
@@ -364,7 +365,7 @@ TALER_PQ_result_spec_json (const char *name,
{
struct GNUNET_PQ_ResultSpec res =
{ &extract_json, &clean_json, NULL,
- (void *) jp, 0,
+ (void *) jp, 0,
name, NULL };
return res;
}