aboutsummaryrefslogtreecommitdiff
path: root/src/mint/taler-mint-httpd_parsing.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2015-07-04 21:27:28 +0200
committerChristian Grothoff <christian@grothoff.org>2015-07-04 21:27:28 +0200
commit49da00cc2b857708d53fc092c0ff2bef96fe08e1 (patch)
treeca3658838d65e723b2d4045b91af1a630906a8e3 /src/mint/taler-mint-httpd_parsing.c
parent841950b910efb6c4d5a280363244e5aef63e89fc (diff)
fix misc small bugs
Diffstat (limited to 'src/mint/taler-mint-httpd_parsing.c')
-rw-r--r--src/mint/taler-mint-httpd_parsing.c55
1 files changed, 53 insertions, 2 deletions
diff --git a/src/mint/taler-mint-httpd_parsing.c b/src/mint/taler-mint-httpd_parsing.c
index 15c7215ea..d48674d2b 100644
--- a/src/mint/taler-mint-httpd_parsing.c
+++ b/src/mint/taler-mint-httpd_parsing.c
@@ -531,6 +531,7 @@ TMH_PARSE_navigate_json (struct MHD_Connection *connection,
if ( (-1 != typ) && (json_typeof (root) != typ))
{
+ *r_json = NULL;
ret = (MHD_YES ==
TMH_RESPONSE_reply_json_pack (connection,
MHD_HTTP_BAD_REQUEST,
@@ -543,6 +544,7 @@ TMH_PARSE_navigate_json (struct MHD_Connection *connection,
break;
}
*r_json = root;
+ json_incref ((json_t *) root);
ret = GNUNET_OK;
}
break;
@@ -793,7 +795,7 @@ TMH_PARSE_json_data (struct MHD_Connection *connection,
TMH_PARSE_JNC_FIELD,
spec[i].field_name,
TMH_PARSE_JNC_RET_AMOUNT,
- &spec[i].destination);
+ spec[i].destination);
break;
case TMH_PARSE_JNC_RET_TIME_ABSOLUTE:
GNUNET_assert (sizeof (struct GNUNET_TIME_Absolute) ==
@@ -803,7 +805,7 @@ TMH_PARSE_json_data (struct MHD_Connection *connection,
TMH_PARSE_JNC_FIELD,
spec[i].field_name,
TMH_PARSE_JNC_RET_TIME_ABSOLUTE,
- &spec[i].destination);
+ spec[i].destination);
break;
}
}
@@ -1049,5 +1051,54 @@ TMH_PARSE_amount_json (struct MHD_Connection *connection,
}
+/**
+ * Generate line in parser specification for JSON object value.
+ *
+ * @param field name of the field
+ * @param ptraddr address of pointer to JSON to initialize
+ * @return corresponding field spec
+ */
+struct TMH_PARSE_FieldSpecification
+TMH_PARSE_member_object (const char *field,
+ json_t **jsonp)
+{
+ struct TMH_PARSE_FieldSpecification ret =
+ { field, (void **) jsonp, 0, 0, TMH_PARSE_JNC_RET_TYPED_JSON, JSON_OBJECT };
+ return ret;
+}
+
+
+/**
+ * Generate line in parser specification for an absolute time.
+ *
+ * @param field name of the field
+ * @param[out] atime time to initialize
+ */
+struct TMH_PARSE_FieldSpecification
+TMH_PARSE_member_time_abs (const char *field,
+ struct GNUNET_TIME_Absolute *atime)
+{
+ struct TMH_PARSE_FieldSpecification ret =
+ { field, atime, sizeof(struct GNUNET_TIME_Absolute), 0, TMH_PARSE_JNC_RET_TIME_ABSOLUTE, 0 };
+ return ret;
+}
+
+
+/**
+ * Generate line in parser specification for an amount.
+ *
+ * @param field name of the field
+ * @param amount a `struct TALER_Amount *` to initialize
+ * @return corresponding field spec
+ */
+struct TMH_PARSE_FieldSpecification
+TMH_PARSE_member_amount (const char *field,
+ struct TALER_Amount *amount)
+{
+ struct TMH_PARSE_FieldSpecification ret =
+ { field, amount, sizeof(struct TALER_Amount), 0, TMH_PARSE_JNC_RET_AMOUNT, 0 };
+ return ret;
+}
+
/* end of taler-mint-httpd_parsing.c */