From ea5b21b58c9ce5b232389de334514552f43d4bfb Mon Sep 17 00:00:00 2001 From: Philipp Schafft Date: Sat, 10 Oct 2020 09:39:02 +0000 Subject: [PATCH] Feature: Added support for definition, and akindof to handle_node_identification() --- src/xml2json.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/xml2json.c b/src/xml2json.c index f05ce7b7..1662d089 100644 --- a/src/xml2json.c +++ b/src/xml2json.c @@ -99,21 +99,21 @@ static int nodelist_is_empty(struct nodelist *list) return 1; } -static void handle_node_identification(json_renderer_t *renderer, const char *name, const char *ns, const char *id) +static void handle_node_identification(json_renderer_t *renderer, const char *name, const char *ns, const char *id, const char *definition, const char *akindof) { json_renderer_begin(renderer, JSON_ELEMENT_TYPE_OBJECT); - if (name) { - json_renderer_write_key(renderer, "name", JSON_RENDERER_FLAGS_NONE); - json_renderer_write_string(renderer, name, JSON_RENDERER_FLAGS_NONE); - } - if (ns) { - json_renderer_write_key(renderer, "ns", JSON_RENDERER_FLAGS_NONE); - json_renderer_write_string(renderer, ns, JSON_RENDERER_FLAGS_NONE); - } - if (id) { - json_renderer_write_key(renderer, "id", JSON_RENDERER_FLAGS_NONE); - json_renderer_write_string(renderer, id, JSON_RENDERER_FLAGS_NONE); +#define handle_node_identification__single(name) \ + if ((name)) { \ + json_renderer_write_key(renderer, ( # name ), JSON_RENDERER_FLAGS_NONE); \ + json_renderer_write_string(renderer, (name), JSON_RENDERER_FLAGS_NONE); \ } + + handle_node_identification__single(name) + handle_node_identification__single(ns) + handle_node_identification__single(id) + handle_node_identification__single(definition) + handle_node_identification__single(akindof) + json_renderer_end(renderer); } @@ -188,7 +188,7 @@ static void render_node_legacyresponse(json_renderer_t *renderer, xmlDocPtr doc, handled = 1; if (strcmp(nodename, "iceresponse") == 0) { json_renderer_begin(renderer, JSON_ELEMENT_TYPE_ARRAY); - handle_node_identification(renderer, "iceresponse", XMLNS_LEGACY_RESPONSE, NULL); + handle_node_identification(renderer, "iceresponse", XMLNS_LEGACY_RESPONSE, NULL, NULL, NULL); json_renderer_begin(renderer, JSON_ELEMENT_TYPE_OBJECT); if (node->xmlChildrenNode) { xmlNodePtr cur = node->xmlChildrenNode; @@ -326,7 +326,7 @@ static void render_node_legacystats(json_renderer_t *renderer, xmlDocPtr doc, xm if (is_icestats) { json_renderer_begin(renderer, JSON_ELEMENT_TYPE_ARRAY); - handle_node_identification(renderer, "icestats", XMLNS_LEGACY_STATS, NULL); + handle_node_identification(renderer, "icestats", XMLNS_LEGACY_STATS, NULL, NULL, NULL); } json_renderer_begin(renderer, JSON_ELEMENT_TYPE_OBJECT); if (node->xmlChildrenNode) {