UPnPsdk 0.1
Universal Plug and Play +, Software Development Kit
 
Loading...
Searching...
No Matches
ixmldebug.cpp
Go to the documentation of this file.
1// Copyright (C) 2022+ GPL 3 and higher by Ingo Höft, <Ingo@Hoeft-online.de>
2// Redistribution only with this Copyright remark. Last modified: 2025-05-29
3// Taken from authors who haven't made a note.
8#include <ixml/ixmldebug.hpp>
9#include <cstdarg>
10#include <cstdio>
11
12
13void IxmlPrintf(const char* DbgFileName, int DbgLineNo,
14 const char* FunctionName, const char* FmtStr, ...) {
15 va_list ArgList;
16
17 FILE* fp = stdout;
18 fprintf(fp, "(%s::%s), line %d", DbgFileName, FunctionName, DbgLineNo);
19 if (FmtStr) {
20 fprintf(fp, ": ");
21 va_start(ArgList, FmtStr);
22 vfprintf(fp, FmtStr, ArgList);
23 // umock::stdio_h.fflush(fp);
24 fflush(fp);
25 va_end(ArgList);
26 } else {
27 fprintf(fp, "\n");
28 }
29}
30
31void printNodes(IXML_Node* tmpRoot, int depth) {
32 unsigned long i;
33 IXML_NodeList* NodeList1;
34 IXML_Node* ChildNode1;
35 unsigned short NodeType;
36 const DOMString NodeValue;
37 const DOMString NodeName;
38 NodeList1 = ixmlNode_getChildNodes(tmpRoot);
39 for (i = 0; i < 100; ++i) {
40 ChildNode1 = ixmlNodeList_item(NodeList1, i);
41 if (ChildNode1 == NULL) {
42 break;
43 }
44
45 printNodes(ChildNode1, depth + 1);
46 NodeType = ixmlNode_getNodeType(ChildNode1);
47 NodeValue = ixmlNode_getNodeValue(ChildNode1);
48 NodeName = ixmlNode_getNodeName(ChildNode1);
49 IxmlPrintf(__FILE__, __LINE__, "printNodes",
50 "DEPTH-%2d-IXML_Node Type %d, "
51 "IXML_Node Name: %s, IXML_Node Value: %s\n",
52 depth, NodeType, NodeName, NodeValue);
53 }
54}
Data structure common to all types of nodes.
Definition ixml.hpp:132
Data structure representing a list of nodes.
Definition ixml.hpp:193
PUPNP_Api unsigned short ixmlNode_getNodeType(IXML_Node *nodeptr)
Retrieves the type of a Node. Note that not all possible return values are actually implemented.
Definition node.cpp:326
#define DOMString
The type of DOM strings.
Definition ixml.hpp:47
PUPNP_Api const DOMString ixmlNode_getNodeValue(IXML_Node *nodeptr)
Returns the value of the Node as a string.
Definition node.cpp:296
PUPNP_Api const DOMString ixmlNode_getNodeName(IXML_Node *nodeptr)
Returns the name of the Node, depending on what type of Node it is, in a read-only string.
Definition node.cpp:179
PUPNP_Api IXML_NodeList * ixmlNode_getChildNodes(IXML_Node *nodeptr)
Retrieves the list of children of a Node in a NodeList structure.
Definition node.cpp:1096
PUPNP_Api IXML_Node * ixmlNodeList_item(IXML_NodeList *nList, unsigned long index)
Retrieves a Node from a NodeList specified by a numerical index.
Definition nodeList.cpp:49
void IxmlPrintf(const char *DbgFileName, int DbgLineNo, const char *FunctionName, const char *FmtStr,...)
Prints the debug statement either on the standard output or log file along with the information from ...
Definition ixmldebug.cpp:13
void printNodes(IXML_Node *tmpRoot, int depth)
Print the node names and values of a XML tree.
Definition ixmldebug.cpp:31
Auxiliar routines to aid debugging.