aboutsummaryrefslogtreecommitdiff
path: root/src/util/wireformats.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/wireformats.c')
-rw-r--r--src/util/wireformats.c39
1 files changed, 37 insertions, 2 deletions
diff --git a/src/util/wireformats.c b/src/util/wireformats.c
index 7ea4fd067..88af4a438 100644
--- a/src/util/wireformats.c
+++ b/src/util/wireformats.c
@@ -330,7 +330,7 @@ validate_sepa (const json_t *wire)
((json_t *) wire,
&error, JSON_STRICT,
"{"
- "s:s " /* type: "SEPA" */
+ "s:s " /* TYPE: sepa */
"s:s " /* IBAN: iban */
"s:s " /* name: beneficiary name */
"s:s " /* BIC: beneficiary bank's BIC */
@@ -345,7 +345,6 @@ validate_sepa (const json_t *wire)
"edate", &edate,
"r", &r,
"address", &address));
- EXITIF (0 != strcmp (type, "SEPA"));
if (1 != validate_iban (iban))
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
@@ -360,6 +359,20 @@ validate_sepa (const json_t *wire)
/**
+ * Validate TEST account details. The "test" format is used
+ * for testing, so this validator does nothing.
+ *
+ * @param wire JSON with the TEST details
+ * @return #GNUNET_YES if correctly formatted; #GNUNET_NO if not
+ */
+static int
+validate_test (const json_t *wire)
+{
+ return GNUNET_YES;
+}
+
+
+/**
* Handler for a wire format.
*/
struct FormatHandler
@@ -392,9 +405,29 @@ TALER_json_validate_wireformat (const char *type,
{
static const struct FormatHandler format_handlers[] = {
{ "SEPA", &validate_sepa },
+ { "TEST", &validate_test },
{ NULL, NULL}
};
unsigned int i;
+ char *stype;
+ json_error_t error;
+
+ UNPACK_EXITIF (0 != json_unpack_ex
+ ((json_t *) wire,
+ &error, 0,
+ "{"
+ "s:s " /* TYPE: type */
+ "}",
+ "type", &stype));
+ if (0 != strcasecmp (type,
+ stype))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Wireformat `%s' does not match mint's expected `%s' format\n",
+ stype,
+ type);
+ return GNUNET_NO;
+ }
for (i=0;NULL != format_handlers[i].type;i++)
if (0 == strcasecmp (format_handlers[i].type,
@@ -404,6 +437,8 @@ TALER_json_validate_wireformat (const char *type,
"Wireformat `%s' not supported\n",
type);
return GNUNET_NO;
+ EXITIF_exit:
+ return GNUNET_NO;
}
/* end of wireformats.c */