diff options
author | Christian Grothoff <christian@grothoff.org> | 2015-09-20 13:48:15 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2015-09-20 13:48:15 +0200 |
commit | a6f8fa98b0253091cae0f2e38fb5fcec47e115fa (patch) | |
tree | c505f31400c14486ad68cdb237decc8fa35ca117 /src/util/wireformats.c | |
parent | 1eadd66ae0c4abe6867321bcac0ad2f9832a0baf (diff) |
implement #3972: support multiple wire formats concurrently
Diffstat (limited to 'src/util/wireformats.c')
-rw-r--r-- | src/util/wireformats.c | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/src/util/wireformats.c b/src/util/wireformats.c index 88af4a438..5f9678526 100644 --- a/src/util/wireformats.c +++ b/src/util/wireformats.c @@ -395,12 +395,12 @@ struct FormatHandler /** * Check if the given wire format JSON object is correctly formatted * - * @param type the expected type of the wire format + * @param allowed NULL-terminated array of allowed wire format types * @param wire the JSON wire format object * @return #GNUNET_YES if correctly formatted; #GNUNET_NO if not */ int -TALER_json_validate_wireformat (const char *type, +TALER_json_validate_wireformat (const char **allowed, const json_t *wire) { static const struct FormatHandler format_handlers[] = { @@ -409,33 +409,33 @@ TALER_json_validate_wireformat (const char *type, { NULL, NULL} }; unsigned int i; - char *stype; + const char *stype; json_error_t error; UNPACK_EXITIF (0 != json_unpack_ex ((json_t *) wire, &error, 0, - "{" - "s:s " /* TYPE: type */ - "}", + "{s:s}", "type", &stype)); - if (0 != strcasecmp (type, - stype)) + for (i=0;NULL != allowed[i];i++) + if (0 == strcasecmp (allowed[i], + stype)) + break; + if (NULL == allowed[i]) { GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "Wireformat `%s' does not match mint's expected `%s' format\n", - stype, - type); + "Wireformat `%s' does not match mint's allowed formats\n", + stype); return GNUNET_NO; } for (i=0;NULL != format_handlers[i].type;i++) if (0 == strcasecmp (format_handlers[i].type, - type)) + stype)) return format_handlers[i].handler (wire); GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Wireformat `%s' not supported\n", - type); + stype); return GNUNET_NO; EXITIF_exit: return GNUNET_NO; |