Improoving IXML debugging.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@378 119443c7-1b9e-41f8-b6fc-b9c35fce742c
This commit is contained in:
parent
e90e549cbb
commit
9a98f25b95
@ -24,15 +24,23 @@ libixml_la_LDFLAGS = -version-info $(LT_VERSION_IXML) \
|
|||||||
-export-symbols-regex '^ixml.*'
|
-export-symbols-regex '^ixml.*'
|
||||||
|
|
||||||
libixml_la_SOURCES = \
|
libixml_la_SOURCES = \
|
||||||
src/ixml.c src/node.c src/ixmlparser.c \
|
src/attr.c \
|
||||||
src/ixmlmembuf.c src/nodeList.c \
|
src/document.c \
|
||||||
src/element.c src/attr.c src/document.c \
|
src/element.c \
|
||||||
|
src/inc/ixmlmembuf.h \
|
||||||
|
src/inc/ixmlparser.h \
|
||||||
|
src/ixml.c \
|
||||||
|
src/ixmldebug.c \
|
||||||
|
src/ixmldebug.h \
|
||||||
|
src/ixmlparser.c \
|
||||||
|
src/ixmlmembuf.c \
|
||||||
src/namedNodeMap.c \
|
src/namedNodeMap.c \
|
||||||
src/inc/ixmlmembuf.h src/inc/ixmlparser.h
|
src/node.c \
|
||||||
|
src/nodeList.c
|
||||||
|
|
||||||
upnpincludedir = $(includedir)/upnp
|
upnpincludedir = $(includedir)/upnp
|
||||||
upnpinclude_HEADERS = inc/ixml.h
|
upnpinclude_HEADERS = inc/ixml.h \
|
||||||
|
inc/ixmldebug.h
|
||||||
|
|
||||||
check_PROGRAMS = test_document
|
check_PROGRAMS = test_document
|
||||||
TESTS = test/test_document.sh
|
TESTS = test/test_document.sh
|
||||||
@ -47,4 +55,3 @@ dist-hook:
|
|||||||
clean-local:
|
clean-local:
|
||||||
@if [ -d bin ] ; then rm -rf bin ; fi
|
@if [ -d bin ] ; then rm -rf bin ; fi
|
||||||
|
|
||||||
|
|
||||||
|
@ -52,15 +52,26 @@
|
|||||||
#ifdef LIBUPNP_EXPORTS
|
#ifdef LIBUPNP_EXPORTS
|
||||||
/* set up declspec for dll export to make functions visible to library users */
|
/* set up declspec for dll export to make functions visible to library users */
|
||||||
#define EXPORT_SPEC __declspec(dllexport)
|
#define EXPORT_SPEC __declspec(dllexport)
|
||||||
#else
|
#else /* LIBUPNP_EXPORTS */
|
||||||
#define EXPORT_SPEC __declspec(dllimport)
|
#define EXPORT_SPEC __declspec(dllimport)
|
||||||
#endif
|
#endif /* LIBUPNP_EXPORTS */
|
||||||
#else
|
#else /* UPNP_STATIC_LIB */
|
||||||
#define EXPORT_SPEC
|
#define EXPORT_SPEC
|
||||||
#endif
|
#endif /* UPNP_STATIC_LIB */
|
||||||
#else
|
|
||||||
|
|
||||||
|
#ifdef UPNP_USE_MSVCPP
|
||||||
|
/* define some things the M$ VC++ doesn't know */
|
||||||
|
#define IXML_INLINE
|
||||||
|
#endif /* UPNP_USE_MSVCPP */
|
||||||
|
#ifdef UPNP_USE_BCBPP
|
||||||
|
/* define some things Borland Builder doesn't know */
|
||||||
|
#define IXML_INLINE inline
|
||||||
|
#endif /* UPNP_USE_BCBPP */
|
||||||
|
#else /* WIN32 */
|
||||||
#define EXPORT_SPEC
|
#define EXPORT_SPEC
|
||||||
#endif
|
#define IXML_INLINE inline
|
||||||
|
#endif /* WIN32 */
|
||||||
|
|
||||||
typedef int BOOL;
|
typedef int BOOL;
|
||||||
|
|
||||||
|
34
ixml/inc/ixmldebug.h
Normal file
34
ixml/inc/ixmldebug.h
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
|
||||||
|
|
||||||
|
#ifndef IXMLDEBUG_H
|
||||||
|
#define IXMLDEBUG_H
|
||||||
|
|
||||||
|
|
||||||
|
#include "ixml.h"
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Prints the debug statement either on the standard output or log file
|
||||||
|
* along with the information from where this debug statement is coming.
|
||||||
|
**/
|
||||||
|
#ifdef DEBUG
|
||||||
|
void IxmlPrintf(
|
||||||
|
/*! [in] Printf like format specification. */
|
||||||
|
const char* FmtStr,
|
||||||
|
/*! [in] Printf like Variable number of arguments that will go in the debug
|
||||||
|
* statement. */
|
||||||
|
...)
|
||||||
|
#if (__GNUC__ >= 3)
|
||||||
|
/* This enables printf like format checking by the compiler */
|
||||||
|
__attribute__((format (__printf__, 1, 2)))
|
||||||
|
#endif
|
||||||
|
;
|
||||||
|
#else /* DEBUG */
|
||||||
|
static IXML_INLINE void IxmlPrintf(
|
||||||
|
const char* FmtStr,
|
||||||
|
...) {}
|
||||||
|
#endif /* DEBUG */
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* IXMLDEBUG_H */
|
||||||
|
|
@ -29,6 +29,7 @@
|
|||||||
//
|
//
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include "ixmldebug.h"
|
||||||
#include "ixmlmembuf.h"
|
#include "ixmlmembuf.h"
|
||||||
#include "ixmlparser.h"
|
#include "ixmlparser.h"
|
||||||
|
|
||||||
|
26
ixml/src/ixmldebug.c
Normal file
26
ixml/src/ixmldebug.c
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
|
||||||
|
|
||||||
|
#include "autoconfig.h"
|
||||||
|
|
||||||
|
|
||||||
|
#include "ixmldebug.h"
|
||||||
|
|
||||||
|
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
|
void IxmlPrintf(
|
||||||
|
const char *FmtStr,
|
||||||
|
... )
|
||||||
|
{
|
||||||
|
va_list ArgList;
|
||||||
|
|
||||||
|
va_start(ArgList, FmtStr);
|
||||||
|
vfprintf(stdout, FmtStr, ArgList);
|
||||||
|
fflush(stdout);
|
||||||
|
va_end(ArgList);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
@ -29,9 +29,13 @@
|
|||||||
//
|
//
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
|
#include "ixmldebug.h"
|
||||||
#include "ixmlparser.h"
|
#include "ixmlparser.h"
|
||||||
|
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
#define strncasecmp strnicmp
|
#define strncasecmp strnicmp
|
||||||
#endif
|
#endif
|
||||||
@ -2433,77 +2437,105 @@ Parser_processAttribute( IN Parser * xmlParser,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*==============================================================================*
|
/*==============================================================================*
|
||||||
*
|
*
|
||||||
* Parser_getNextNode
|
* Parser_getNextNode
|
||||||
* return next node
|
* return next node
|
||||||
* returns IXML_SUCCESS or
|
* returns IXML_SUCCESS or
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
*===============================================================================*/
|
*===============================================================================*/
|
||||||
static int
|
static int Parser_getNextNode(
|
||||||
Parser_getNextNode( IN Parser * xmlParser,
|
IN Parser *xmlParser,
|
||||||
OUT IXML_Node * node,
|
OUT IXML_Node *node,
|
||||||
OUT BOOL * bETag )
|
OUT BOOL *bETag )
|
||||||
{
|
{
|
||||||
char *pCurToken = NULL;
|
char *pCurToken = NULL;
|
||||||
char *lastElement = NULL;
|
char *lastElement = NULL;
|
||||||
|
IXML_ERRORCODE ret = IXML_SUCCESS;
|
||||||
|
int line = 0;
|
||||||
|
int tokenLen = 0;
|
||||||
|
|
||||||
// endof file reached?
|
// endof file reached?
|
||||||
if( *( xmlParser->curPtr ) == '\0' ) {
|
if (*(xmlParser->curPtr) == '\0') {
|
||||||
*bETag = TRUE;
|
*bETag = TRUE;
|
||||||
return IXML_FILE_DONE;
|
line = __LINE__;
|
||||||
}
|
ret = IXML_FILE_DONE;
|
||||||
|
goto ExitFunction;
|
||||||
|
}
|
||||||
|
|
||||||
if( xmlParser->state == eCONTENT ) {
|
if (xmlParser->state == eCONTENT) {
|
||||||
if( Parser_processContent( xmlParser, node ) != IXML_SUCCESS ) {
|
line = __LINE__;
|
||||||
return IXML_FAILED;
|
ret = Parser_processContent(xmlParser, node);
|
||||||
}
|
goto ExitFunction;
|
||||||
} else {
|
} else {
|
||||||
Parser_skipWhiteSpaces( xmlParser );
|
Parser_skipWhiteSpaces(xmlParser);
|
||||||
|
tokenLen = Parser_getNextToken(xmlParser);
|
||||||
|
if (tokenLen == 0 &&
|
||||||
|
xmlParser->pCurElement == NULL &&
|
||||||
|
*(xmlParser->curPtr) == '\0') {
|
||||||
|
// comments after the xml doc
|
||||||
|
line = __LINE__;
|
||||||
|
ret = IXML_SUCCESS;
|
||||||
|
goto ExitFunction;
|
||||||
|
} else if ((xmlParser->tokenBuf).length == 0) {
|
||||||
|
line = __LINE__;
|
||||||
|
ret = IXML_SYNTAX_ERR;
|
||||||
|
goto ExitFunction;
|
||||||
|
}
|
||||||
|
|
||||||
if( ( Parser_getNextToken( xmlParser ) == 0 ) && ( xmlParser->pCurElement == NULL ) && ( *( xmlParser->curPtr ) == '\0' ) ) { // comments after the xml doc
|
pCurToken = (xmlParser->tokenBuf).buf;
|
||||||
return IXML_SUCCESS;
|
if (*pCurToken == GREATERTHAN) {
|
||||||
} else if( ( xmlParser->tokenBuf ).length == 0 ) {
|
line = __LINE__;
|
||||||
return IXML_SYNTAX_ERR;
|
ret = IXML_SUCCESS;
|
||||||
}
|
goto ExitFunction;
|
||||||
|
} else if (strcmp(pCurToken, ENDTAG) == 0) {
|
||||||
|
// we got </, read next element
|
||||||
|
line = __LINE__;
|
||||||
|
ret = Parser_processETag(xmlParser, node, bETag);
|
||||||
|
goto ExitFunction;
|
||||||
|
} else if (*pCurToken == LESSTHAN) {
|
||||||
|
line = __LINE__;
|
||||||
|
ret = Parser_processSTag(xmlParser, node);
|
||||||
|
goto ExitFunction;
|
||||||
|
} else if (strcmp(pCurToken, COMPLETETAG) == 0) {
|
||||||
|
lastElement = (xmlParser->lastElem).buf;
|
||||||
|
if (lastElement == NULL) {
|
||||||
|
line = __LINE__;
|
||||||
|
ret = IXML_SYNTAX_ERR;
|
||||||
|
goto ExitFunction;
|
||||||
|
}
|
||||||
|
|
||||||
pCurToken = ( xmlParser->tokenBuf ).buf;
|
node->nodeName = safe_strdup( lastElement );
|
||||||
if( *pCurToken == GREATERTHAN ) {
|
if( node->nodeName == NULL ) {
|
||||||
return IXML_SUCCESS;
|
line = __LINE__;
|
||||||
} else if( strcmp( pCurToken, ENDTAG ) == 0 ) { // we got </, read next element
|
ret = IXML_INSUFFICIENT_MEMORY;
|
||||||
return Parser_processETag( xmlParser, node, bETag );
|
goto ExitFunction;
|
||||||
} else if( *pCurToken == LESSTHAN ) {
|
}
|
||||||
return Parser_processSTag( xmlParser, node );
|
node->nodeType = eELEMENT_NODE;
|
||||||
} else if( strcmp( pCurToken, COMPLETETAG ) == 0 ) {
|
*bETag = TRUE;
|
||||||
lastElement = ( xmlParser->lastElem ).buf;
|
|
||||||
if( lastElement == NULL ) {
|
|
||||||
goto ErrorHandler;
|
|
||||||
}
|
|
||||||
|
|
||||||
node->nodeName = safe_strdup( lastElement );
|
line = __LINE__;
|
||||||
if( node->nodeName == NULL ) {
|
ret = IXML_SUCCESS;
|
||||||
return IXML_INSUFFICIENT_MEMORY;
|
goto ExitFunction;
|
||||||
}
|
} else if (xmlParser->state == eATTRIBUTE && xmlParser->pCurElement != NULL) {
|
||||||
node->nodeType = eELEMENT_NODE;
|
if(Parser_processAttribute( xmlParser, node ) != IXML_SUCCESS) {
|
||||||
*bETag = TRUE;
|
line = __LINE__;
|
||||||
|
ret = IXML_SYNTAX_ERR;
|
||||||
|
goto ExitFunction;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
line = __LINE__;
|
||||||
|
ret = IXML_SYNTAX_ERR;
|
||||||
|
goto ExitFunction;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return IXML_SUCCESS;
|
ExitFunction:
|
||||||
} else if( (xmlParser->state == eATTRIBUTE) &&
|
if (ret != IXML_SUCCESS) {
|
||||||
(xmlParser->pCurElement != NULL) ) {
|
IxmlPrintf("(ixml::Parser_getNextNode): Error %d, line %d\n",
|
||||||
if( Parser_processAttribute( xmlParser, node ) !=
|
ret, line);
|
||||||
IXML_SUCCESS ) {
|
}
|
||||||
return IXML_SYNTAX_ERR;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return IXML_SYNTAX_ERR;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return IXML_SUCCESS;
|
|
||||||
|
|
||||||
ErrorHandler:
|
|
||||||
|
|
||||||
return IXML_SYNTAX_ERR;
|
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,19 +69,21 @@
|
|||||||
#ifdef LIBUPNP_EXPORTS
|
#ifdef LIBUPNP_EXPORTS
|
||||||
/* set up declspec for dll export to make functions visible to library users */
|
/* set up declspec for dll export to make functions visible to library users */
|
||||||
#define EXPORT_SPEC __declspec(dllexport)
|
#define EXPORT_SPEC __declspec(dllexport)
|
||||||
#else
|
#else /* LIBUPNP_EXPORTS */
|
||||||
#define EXPORT_SPEC __declspec(dllimport)
|
#define EXPORT_SPEC __declspec(dllimport)
|
||||||
#endif
|
#endif /* LIBUPNP_EXPORTS */
|
||||||
#else
|
#else /* UPNP_STATIC_LIB */
|
||||||
#define EXPORT_SPEC
|
#define EXPORT_SPEC
|
||||||
#endif
|
#endif /* UPNP_STATIC_LIB */
|
||||||
|
|
||||||
|
|
||||||
#ifdef UPNP_USE_MSVCPP
|
#ifdef UPNP_USE_MSVCPP
|
||||||
/* define some things the M$ VC++ doesn't know */
|
/* define some things the M$ VC++ doesn't know */
|
||||||
#define UPNP_INLINE
|
#define UPNP_INLINE
|
||||||
typedef __int64 int64_t;
|
typedef __int64 int64_t;
|
||||||
#define PRId64 "I64d"
|
#define PRId64 "I64d"
|
||||||
#define PRIzu "lu"
|
#define PRIzu "lu"
|
||||||
#endif
|
#endif /* UPNP_USE_MSVCPP */
|
||||||
#ifdef UPNP_USE_BCBPP
|
#ifdef UPNP_USE_BCBPP
|
||||||
/* define some things Borland Builder doesn't know */
|
/* define some things Borland Builder doesn't know */
|
||||||
#define UPNP_INLINE inline
|
#define UPNP_INLINE inline
|
||||||
@ -89,7 +91,7 @@
|
|||||||
#warning The Borland C compiler is probably broken on PRId64, please someone provide a proper fix here
|
#warning The Borland C compiler is probably broken on PRId64, please someone provide a proper fix here
|
||||||
#define PRId64 "I64d"
|
#define PRId64 "I64d"
|
||||||
#define PRIzu "zu"
|
#define PRIzu "zu"
|
||||||
#endif
|
#endif /* UPNP_USE_BCBPP */
|
||||||
#else
|
#else
|
||||||
#define EXPORT_SPEC
|
#define EXPORT_SPEC
|
||||||
#define UPNP_INLINE inline
|
#define UPNP_INLINE inline
|
||||||
|
@ -229,34 +229,25 @@ static UPNP_INLINE int DebugAtThisLevel(
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/***************************************************************************
|
/*!
|
||||||
* Function : UpnpPrintf
|
* \brief Prints the debug statement either on the standard output or log file
|
||||||
*
|
* along with the information from where this debug statement is coming.
|
||||||
* Parameters:
|
**/
|
||||||
* IN Upnp_LogLevel DLevel: The level of the debug logging. It will decide
|
|
||||||
* whether debug statement will go to standard output,
|
|
||||||
* or any of the log files.
|
|
||||||
* IN Dbg_Module Module: debug will go in the name of this module
|
|
||||||
* IN char *DbgFileName: Name of the file from where debug statement is
|
|
||||||
* coming
|
|
||||||
* IN int DbgLineNo : Line number of the file from where debug statement
|
|
||||||
* is coming
|
|
||||||
* IN char * FmtStr, ...: Variable number of arguments that will go
|
|
||||||
* in the debug statement
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* This functions prints the debug statement either on the startdard
|
|
||||||
* output or log file along with the information from where this
|
|
||||||
* debug statement is coming
|
|
||||||
* Returns: void
|
|
||||||
***************************************************************************/
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
void UpnpPrintf(
|
void UpnpPrintf(
|
||||||
|
/*! [in] The level of the debug logging. It will decide whether debug
|
||||||
|
* statement will go to standard output, or any of the log files. */
|
||||||
Upnp_LogLevel DLevel,
|
Upnp_LogLevel DLevel,
|
||||||
|
/*! [in] debug will go in the name of this module. */
|
||||||
Dbg_Module Module,
|
Dbg_Module Module,
|
||||||
|
/*! [in] Name of the file from where debug statement is coming. */
|
||||||
const char* DbgFileName,
|
const char* DbgFileName,
|
||||||
|
/*! [in] Line number of the file from where debug statement is coming. */
|
||||||
int DbgLineNo,
|
int DbgLineNo,
|
||||||
|
/*! [in] Printf like format specification. */
|
||||||
const char* FmtStr,
|
const char* FmtStr,
|
||||||
|
/*! [in] Printf like Variable number of arguments that will go in the debug
|
||||||
|
* statement. */
|
||||||
...)
|
...)
|
||||||
#if (__GNUC__ >= 3)
|
#if (__GNUC__ >= 3)
|
||||||
/* This enables printf like format checking by the compiler */
|
/* This enables printf like format checking by the compiler */
|
||||||
|
@ -30,12 +30,16 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "upnpdebug.h"
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include "ithread.h"
|
#include "ithread.h"
|
||||||
#include "upnp.h"
|
#include "upnp.h"
|
||||||
|
#include "upnpdebug.h"
|
||||||
|
|
||||||
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
|
||||||
@ -189,27 +193,6 @@ int DebugAtThisLevel(
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/***************************************************************************
|
|
||||||
* Function : UpnpPrintf
|
|
||||||
*
|
|
||||||
* Parameters:
|
|
||||||
* IN Upnp_LogLevel DLevel: The level of the debug logging. It will decide
|
|
||||||
* whether debug statement will go to standard output,
|
|
||||||
* or any of the log files.
|
|
||||||
* IN Dbg_Module Module: debug will go in the name of this module
|
|
||||||
* IN char *DbgFileName: Name of the file from where debug statement is
|
|
||||||
* coming
|
|
||||||
* IN int DbgLineNo : Line number of the file from where debug statement
|
|
||||||
* is coming
|
|
||||||
* IN char * FmtStr, ...: Variable number of arguments that will go
|
|
||||||
* in the debug statement
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* This functions prints the debug statement either on the startdard
|
|
||||||
* output or log file along with the information from where this debug
|
|
||||||
* statement is coming
|
|
||||||
* Returns: void
|
|
||||||
***************************************************************************/
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
void UpnpPrintf(
|
void UpnpPrintf(
|
||||||
IN Upnp_LogLevel DLevel,
|
IN Upnp_LogLevel DLevel,
|
||||||
|
Loading…
Reference in New Issue
Block a user