From bcac161dab0bf24d9b6d0b888bd14d297a4c2a98 Mon Sep 17 00:00:00 2001
From: Jakob Olsson <jakobols@kth.se>
Date: Tue, 5 Jun 2018 11:01:28 +0200
Subject: [PATCH] common changes

---
 common.c | 28 ++++++++++------------------
 1 file changed, 10 insertions(+), 18 deletions(-)

diff --git a/common.c b/common.c
index b0b1302..8e31a23 100644
--- a/common.c
+++ b/common.c
@@ -76,7 +76,7 @@ char *xml_parser(struct write_result *result, char *tag)
 		for (n = 0; nodeset_ptr && n < xmlXPathNodeSetGetLength(nodeset_ptr); n++)
 		{
 			//if (DEBUG)
-			//printf("n value: %d\n", n);
+		//debug_print("n value: %d\n", n);
 			xmlNodePtr node_ptr = nodeset_ptr->nodeTab[n];
 			if (node_ptr->type != XML_ATTRIBUTE_NODE && node_ptr->type != XML_ELEMENT_NODE && node_ptr->type != XML_CDATA_SECTION_NODE)
 				continue;
@@ -84,8 +84,7 @@ char *xml_parser(struct write_result *result, char *tag)
 			{
 				//tag_content = (char*) node_ptr->children->content;
 				strcpy(tag_content, (char *)node_ptr->children->content);
-				if (DEBUG)
-					printf("tag content: %s\n", tag_content);
+				debug_print("tag content: %s\n", tag_content);
 				break;
 			}
 		}
@@ -111,23 +110,18 @@ void xml_to_json(xmlNode *anode, json_object *jobj)
 
 	for (cur_node = anode; cur_node; cur_node = cur_node->next)
 	{
-		if (DEBUG_COMMON)
-		{
-			printf("child address: %p\n", cur_node);
-			printf("next addres: %p\n", cur_node->next);
-			printf("root child content: %s\n", (uint8_t *)xmlNodeGetContent(cur_node));
-		}
+		debug_print("child address: %p\n", cur_node);
+		debug_print("next addres: %p\n", cur_node->next);
+		debug_print("root child content: %s\n", (uint8_t *)xmlNodeGetContent(cur_node));
 
 		if (cur_node->type == XML_ELEMENT_NODE)
 		{
 			if (xmlChildElementCount(cur_node) == 0)
 			{
 				cur_jstr = json_object_new_string((char *)xmlNodeGetContent(cur_node));
-				if (DEBUG_COMMON)
-				{
-					printf("xmlNodeGet name: %sn", (char *)cur_node->name);
-					printf("xmlNodeGetContent: %sn", (char *)xmlNodeGetContent(cur_node));
-				}
+
+				debug_print("xmlNodeGet name: %sn", (char *)cur_node->name);
+				debug_print("xmlNodeGetContent: %sn", (char *)xmlNodeGetContent(cur_node));
 
 				json_object_object_add(jobj, (char *)cur_node->name, cur_jstr);
 			}
@@ -150,8 +144,6 @@ void xml_to_json_converter(struct write_result *result)
 
 	jobj = json_object_new_object();
 	xml_to_json(origin_node, jobj);
-	if (DEBUG_COMMON)
-	{
-		printf("The json object created: %s\n", json_object_to_json_string(jobj));
-	}
+
+	debug_print("The json object created: %s\n", json_object_to_json_string(jobj));
 }
-- 
GitLab