SF Patch Tracker [ 2987390 ] upnp_debug vs. ixml_debug

Thanks for the load of updates, I'm still assimilating them ! Could I make
	a suggestion though? The addition of printNodes(IXML_Node) to upnpdebug a
	dds a new dependency on ixml.h for anything using upnpdebug.h. I'm making
	quite a bit of use of upnpdebug in porting things to version 1.8.0, and I'd
	prefer it if printNodes could be added to ixmldebug.h instead. I'm attach
	ing a patch, what do you think ?

	Nick



git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@532 119443c7-1b9e-41f8-b6fc-b9c35fce742c
This commit is contained in:
Marcelo Roberto Jimenez 2010-04-16 13:38:06 +00:00
parent 8f852b1ee9
commit a627df4d10
8 changed files with 107 additions and 85 deletions

View File

@ -2,6 +2,17 @@
Version 1.8.0
*******************************************************************************
2010-03-27 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
SF Patch Tracker [ 2987390 ] upnp_debug vs. ixml_debug
Thanks for the load of updates, I'm still assimilating them ! Could I make
a suggestion though? The addition of printNodes(IXML_Node) to upnpdebug a
dds a new dependency on ixml.h for anything using upnpdebug.h. I'm making
quite a bit of use of upnpdebug in porting things to version 1.8.0, and I'd
prefer it if printNodes could be added to ixmldebug.h instead. I'm attach
ing a patch, what do you think ?
Nick
2010-03-27 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
* Forward port of svn revision 505:
SF Patch Tracker [ 2836704 ] Patch for Solaris10 compilation and usage.

View File

@ -5,6 +5,7 @@
#include "UpnpGlobal.h"
#include "ixml.h"
/*!
@ -20,6 +21,13 @@
*/
#ifdef DEBUG
void IxmlPrintf(
/*! [in] The file name, usually __FILE__. */
const char *DbgFileName,
/*! [in] The line number, usually __LINE__ or a variable that got the
* __LINE__ at the appropriate place. */
int DbgLineNo,
/*! [in] The function name. */
const char *FunctionName,
/*! [in] Printf like format specification. */
const char* FmtStr,
/*! [in] Printf like Variable number of arguments that will go in the debug
@ -27,7 +35,7 @@ void IxmlPrintf(
...)
#if (__GNUC__ >= 3)
/* This enables printf like format checking by the compiler */
__attribute__((format (__printf__, 1, 2)))
__attribute__((format (__printf__, 4, 5)))
#endif
;
#else /* DEBUG */
@ -37,5 +45,23 @@ static UPNP_INLINE void IxmlPrintf(
#endif /* DEBUG */
/*!
* \brief Print the node names and values of a XML tree.
*/
#ifdef DEBUG
void printNodes(
/*! [in] The root of the tree to print. */
IXML_Node *tmpRoot,
/*! [in] The depth to print. */
int depth);
#else
static UPNP_INLINE void printNodes(
IXML_Node *tmpRoot,
int depth)
{
}
#endif
#endif /* IXMLDEBUG_H */

View File

@ -444,17 +444,17 @@ int ixmlDocument_createElementNSEx(
IXML_Element **rtElement)
{
IXML_Element *newElement = NULL;
int errCode = IXML_SUCCESS;
int ret = IXML_SUCCESS;
int line = 0;
if (doc == NULL || namespaceURI == NULL || qualifiedName == NULL) {
line = __LINE__;
errCode = IXML_INVALID_PARAMETER;
ret = IXML_INVALID_PARAMETER;
goto ErrorHandler;
}
errCode = ixmlDocument_createElementEx(doc, qualifiedName, &newElement);
if (errCode != IXML_SUCCESS) {
ret = ixmlDocument_createElementEx(doc, qualifiedName, &newElement);
if (ret != IXML_SUCCESS) {
line = __LINE__;
goto ErrorHandler;
}
@ -464,16 +464,16 @@ int ixmlDocument_createElementNSEx(
line = __LINE__;
ixmlElement_free(newElement);
newElement = NULL;
errCode = IXML_INSUFFICIENT_MEMORY;
ret = IXML_INSUFFICIENT_MEMORY;
goto ErrorHandler;
}
// set the localName and prefix
errCode = ixmlNode_setNodeName((IXML_Node *)newElement, qualifiedName);
if (errCode != IXML_SUCCESS) {
ret = ixmlNode_setNodeName((IXML_Node *)newElement, qualifiedName);
if (ret != IXML_SUCCESS) {
line = __LINE__;
ixmlElement_free(newElement);
newElement = NULL;
errCode = IXML_INSUFFICIENT_MEMORY;
ret = IXML_INSUFFICIENT_MEMORY;
goto ErrorHandler;
}
@ -481,12 +481,11 @@ int ixmlDocument_createElementNSEx(
ErrorHandler:
*rtElement = newElement;
if (errCode != IXML_SUCCESS) {
IxmlPrintf("(%s::ixmlDocument_createElementNSEx): Error %d, line %d\n",
__FILE__, errCode, line);
if (ret != IXML_SUCCESS) {
IxmlPrintf(__FILE__, line, "ixmlDocument_createElementNSEx", "Error %d\n", ret);
}
return errCode;
return ret;
}

View File

@ -181,9 +181,9 @@ static void ixmlPrintDomTreeRecursive(
break;
default:
IxmlPrintf("(%s::ixmlPrintDomTreeRecursive) line %d: "
IxmlPrintf(__FILE__, __LINE__, "ixmlPrintDomTreeRecursive",
"Warning, unknown node type %d\n",
__FILE__, __LINE__, ixmlNode_getNodeType(nodeptr));
ixmlNode_getNodeType(nodeptr));
break;
}
}
@ -253,9 +253,9 @@ static void ixmlPrintDomTree(
break;
default:
IxmlPrintf("(%s::ixmlPrintDomTree) line %d: "
IxmlPrintf(__FILE__, __LINE__, "ixmlPrintDomTree",
"Warning, unknown node type %d\n",
__FILE__, __LINE__, ixmlNode_getNodeType(nodeptr));
ixmlNode_getNodeType(nodeptr));
break;
}
}
@ -324,9 +324,9 @@ static void ixmlDomTreetoString(
break;
default:
IxmlPrintf("(%s::ixmlDomTreetoString) line %d: "
IxmlPrintf(__FILE__, __LINE__, "ixmlPrintDomTreeRecursive",
"Warning, unknown node type %d\n",
__FILE__, __LINE__, ixmlNode_getNodeType(nodeptr));
ixmlNode_getNodeType(nodeptr));
break;
}
}

View File

@ -17,15 +17,54 @@
#ifdef DEBUG
void IxmlPrintf(
const char *DbgFileName,
int DbgLineNo,
const char *FunctionName,
const char *FmtStr,
...)
{
va_list ArgList;
FILE *fp = stdout;
fprintf(fp, "(%s::%s), line %d", DbgFileName, FunctionName, DbgLineNo);
if (FmtStr) {
fprintf(fp, ": ");
va_start(ArgList, FmtStr);
vfprintf(stdout, FmtStr, ArgList);
fflush(stdout);
vfprintf(fp, FmtStr, ArgList);
fflush(fp);
va_end(ArgList);
} else {
fprintf(fp, "\n");
}
}
void printNodes(IXML_Node *tmpRoot, int depth)
{
int i;
IXML_NodeList *NodeList1;
IXML_Node *ChildNode1;
unsigned short NodeType;
const DOMString NodeValue;
const DOMString NodeName;
NodeList1 = ixmlNode_getChildNodes(tmpRoot);
for (i = 0; i < 100; ++i) {
ChildNode1 = ixmlNodeList_item(NodeList1, i);
if (ChildNode1 == NULL) {
break;
}
printNodes(ChildNode1, depth+1);
NodeType = ixmlNode_getNodeType(ChildNode1);
NodeValue = ixmlNode_getNodeValue(ChildNode1);
NodeName = ixmlNode_getNodeName(ChildNode1);
IxmlPrintf(__FILE__, __LINE__, "printNodes",
"DEPTH-%2d-IXML_Node Type %d, "
"IXML_Node Name: %s, IXML_Node Value: %s\n",
depth, NodeType, NodeName, NodeValue);
}
}
#endif

View File

@ -542,8 +542,7 @@ static int Parser_UTF8ToInt(
*len = 0;
ret = -1;
}
IxmlPrintf("(%s::Parser_UTF8ToInt): Error %d, line %d\n",
__FILE__, ret, line);
IxmlPrintf(__FILE__, line, "Parser_UTF8ToInt", "Error %d\n", ret);
return ret;
}
}
@ -1302,8 +1301,7 @@ fail_entity:
ExitFunction:
if (ret == -1 || (g_error_char && ret == g_error_char)) {
IxmlPrintf("(%s::Parser_getChar): Error %d, line %d\n",
__FILE__, ret, line);
IxmlPrintf(__FILE__, line, "Parser_getChar", "Error %d\n", ret);
}
return ret;
@ -1370,8 +1368,7 @@ static int Parser_copyToken(
ExitFunction:
if (ret != IXML_SUCCESS) {
IxmlPrintf("(%s::Parser_copyToken): Error %d, line %d\n",
__FILE__, ret, line);
IxmlPrintf(__FILE__, line, "Parser_copyToken", "Error %d\n", ret);
}
return ret;
@ -1918,8 +1915,7 @@ static int Parser_xmlNamespace(
ExitFunction:
if (ret != IXML_SUCCESS && ret != IXML_FILE_DONE) {
IxmlPrintf("(%s::Parser_xmlNamespace): Error %d, line %d\n",
__FILE__, ret, line);
IxmlPrintf(__FILE__, line, "Parser_xmlNamespace", "Error %d\n", ret);
}
return ret;
@ -2248,8 +2244,7 @@ static int Parser_processContent(
ExitFunction:
if (ret != IXML_SUCCESS) {
IxmlPrintf("(%s::Parser_processContent): Error %d, line %d\n",
__FILE__, ret, line);
IxmlPrintf(__FILE__, line, "Parser_processContent", "Error %d\n", ret);
}
return ret;
@ -2321,8 +2316,7 @@ static int Parser_processETag(
ExitFunction:
if (ret != IXML_SUCCESS) {
IxmlPrintf("(%s::Parser_processETag): Error %d, line %d\n",
__FILE__, ret, line);
IxmlPrintf(__FILE__, line, "Parser_processETag", "Error %d\n", ret);
}
return ret;
@ -2577,8 +2571,7 @@ static int Parser_processAttribute(
ExitFunction:
if (ret != IXML_SUCCESS && ret != IXML_FILE_DONE) {
IxmlPrintf("(%s::Parser_processAttribute): Error %d, line %d\n",
__FILE__, ret, line);
IxmlPrintf(__FILE__, line, "Parser_processAttribute", "Error %d\n", ret);
}
return ret;
@ -2681,8 +2674,7 @@ static int Parser_getNextNode(
ExitFunction:
if (ret != IXML_SUCCESS && ret != IXML_FILE_DONE) {
IxmlPrintf("(%s::Parser_getNextNode): Error %d, line %d\n",
__FILE__, ret, line);
IxmlPrintf(__FILE__, line, "Parser_getNextNode", "Error %d\n", ret);
}
return ret;

View File

@ -304,24 +304,6 @@ static UPNP_INLINE void PrintThreadPoolStats(
#endif
/*!
* \brief Print the node names and values of a XML tree.
*/
#ifdef DEBUG
void printNodes(
/*! [in] The root of the tree to print. */
IXML_Node *tmpRoot,
/*! [in] The depth to print. */
int depth);
#else
static UPNP_INLINE void printNodes(
IXML_Node *tmpRoot,
int depth)
{
}
#endif
/*@}*/
#ifdef __cplusplus

View File

@ -324,32 +324,5 @@ void PrintThreadPoolStats(
}
void printNodes(IXML_Node *tmpRoot, int depth)
{
int i;
IXML_NodeList *NodeList1;
IXML_Node *ChildNode1;
unsigned short NodeType;
const DOMString NodeValue;
const DOMString NodeName;
NodeList1 = ixmlNode_getChildNodes(tmpRoot);
for (i = 0; i < 100; ++i) {
ChildNode1 = ixmlNodeList_item(NodeList1, i);
if (ChildNode1 == NULL) {
break;
}
printNodes(ChildNode1, depth+1);
NodeType = ixmlNode_getNodeType(ChildNode1);
NodeValue = ixmlNode_getNodeValue(ChildNode1);
NodeName = ixmlNode_getNodeName(ChildNode1);
UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
"DEPTH-%2d-IXML_Node Type %d, "
"IXML_Node Name: %s, IXML_Node Value: %s\n",
depth, NodeType, NodeName, NodeValue);
}
}
#endif /* DEBUG */