From 3f23417a1099f73dc28ec1b7d6ec2a1a7fc2b7a2 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 18 Jun 2012 20:53:59 +0000 Subject: - PLUGININFO structure removed at all; - Options_AddPage & UserInfo_AddPage replaced MS_OPT_ADDPAGE & MS_USERINFO_ADDPAGE services respectively - total internal redesign of options' translation - code reformatting git-svn-id: http://svn.miranda-ng.org/main/trunk@477 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- src/modules/xml/xmlApi.cpp | 244 +++++++++++++++++----------------- src/modules/xml/xmlParser.cpp | 300 +++++++++++++++++++++--------------------- src/modules/xml/xmlParser.h | 6 +- 3 files changed, 275 insertions(+), 275 deletions(-) (limited to 'src/modules/xml') diff --git a/src/modules/xml/xmlApi.cpp b/src/modules/xml/xmlApi.cpp index c574da4f6d..dc6387b80a 100644 --- a/src/modules/xml/xmlApi.cpp +++ b/src/modules/xml/xmlApi.cpp @@ -24,252 +24,252 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "..\..\core\commonheaders.h" #include "xmlParser.h" -static HXML xmlapiCreateNode( LPCTSTR name, LPCTSTR text, char isDeclaration ) +static HXML xmlapiCreateNode(LPCTSTR name, LPCTSTR text, char isDeclaration) { - XMLNode result = XMLNode::createXMLTopNode( name, isDeclaration ); - if ( text ) - result.updateText( text ); + XMLNode result = XMLNode::createXMLTopNode(name, isDeclaration); + if (text) + result.updateText(text); return result.detach(); } -static void xmlapiDestroyNode( HXML n ) +static void xmlapiDestroyNode(HXML n) { XMLNode tmp; tmp.attach(n); } -static HXML xmlapiParseString( LPCTSTR str, int* datalen, LPCTSTR tag ) +static HXML xmlapiParseString(LPCTSTR str, int* datalen, LPCTSTR tag) { if (str == NULL) return NULL; XMLResults res; - XMLNode result = XMLNode::parseString( str, tag, &res ); + XMLNode result = XMLNode::parseString(str, tag, &res); - if ( datalen != NULL ) + if (datalen != NULL) datalen[0] += res.nChars; return (res.error == eXMLErrorNone || (tag != NULL && res.error == eXMLErrorMissingEndTag)) ? result.detach() : NULL; } -static HXML xmlapiAddChild( HXML _n, LPCTSTR name, LPCTSTR text ) +static HXML xmlapiAddChild(HXML _n, LPCTSTR name, LPCTSTR text) { - XMLNode result = XMLNode(_n).addChild( name ); - if ( text != NULL ) - result.updateText( text ); + XMLNode result = XMLNode(_n).addChild(name); + if (text != NULL) + result.updateText(text); return result; } -static void xmlapiAddChild2( HXML _child, HXML _parent ) +static void xmlapiAddChild2(HXML _child, HXML _parent) { XMLNode child(_child), parent(_parent); - parent.addChild( child ); + parent.addChild(child); } -static HXML xmlapiCopyNode( HXML _n ) +static HXML xmlapiCopyNode(HXML _n) { XMLNode result = XMLNode(_n); return result.detach(); } -static LPCTSTR xmlapiGetAttr( HXML _n, int i ) +static LPCTSTR xmlapiGetAttr(HXML _n, int i) { - return XMLNode(_n).getAttributeValue( i ); + return XMLNode(_n).getAttributeValue(i); } -static int xmlapiGetAttrCount( HXML _n ) +static int xmlapiGetAttrCount(HXML _n) { return XMLNode(_n).nAttribute(); } -static LPCTSTR xmlapiGetAttrName( HXML _n, int i ) +static LPCTSTR xmlapiGetAttrName(HXML _n, int i) { - return XMLNode(_n).getAttributeName( i ); + return XMLNode(_n).getAttributeName(i); } -static HXML xmlapiGetChild( HXML _n, int i ) +static HXML xmlapiGetChild(HXML _n, int i) { - return XMLNode(_n).getChildNode( i ); + return XMLNode(_n).getChildNode(i); } -static HXML xmlapiGetChildByAttrValue( HXML _n, LPCTSTR name, LPCTSTR attrName, LPCTSTR attrValue ) +static HXML xmlapiGetChildByAttrValue(HXML _n, LPCTSTR name, LPCTSTR attrName, LPCTSTR attrValue) { - return XMLNode(_n).getChildNodeWithAttribute( name, attrName, attrValue ); + return XMLNode(_n).getChildNodeWithAttribute(name, attrName, attrValue); } -static int xmlapiGetChildCount( HXML _n ) +static int xmlapiGetChildCount(HXML _n) { return XMLNode(_n).nChildNode(); } -static HXML xmlapiGetFirstChild( HXML _n ) +static HXML xmlapiGetFirstChild(HXML _n) { - return XMLNode(_n).getChildNode( 0 ); + return XMLNode(_n).getChildNode(0); } -static HXML xmlapiGetNthChild( HXML _n, LPCTSTR name, int i ) +static HXML xmlapiGetNthChild(HXML _n, LPCTSTR name, int i) { - return XMLNode(_n).getChildNode( name, i ); + return XMLNode(_n).getChildNode(name, i); } -static HXML xmlapiGetNextChild( HXML _n, LPCTSTR name, int* i ) +static HXML xmlapiGetNextChild(HXML _n, LPCTSTR name, int* i) { - return XMLNode(_n).getChildNode( name, i ); + return XMLNode(_n).getChildNode(name, i); } -static HXML xmlapiGetNextNode( HXML _n ) +static HXML xmlapiGetNextNode(HXML _n) { - return XMLNode(_n).getNextNode( ); + return XMLNode(_n).getNextNode(); } -static HXML xmlapiGetChildByPath( HXML _n, LPCTSTR path, char createNodeIfMissing ) +static HXML xmlapiGetChildByPath(HXML _n, LPCTSTR path, char createNodeIfMissing) { - return XMLNode(_n).getChildNodeByPath( path, createNodeIfMissing ); + return XMLNode(_n).getChildNodeByPath(path, createNodeIfMissing); } -static LPCTSTR xmlapiGetName( HXML _n ) +static LPCTSTR xmlapiGetName(HXML _n) { return XMLNode(_n).getName(); } -static HXML xmlapiGetParent( HXML _n ) +static HXML xmlapiGetParent(HXML _n) { return XMLNode(_n).getParentNode(); } -static LPCTSTR xmlapiGetText( HXML _n ) +static LPCTSTR xmlapiGetText(HXML _n) { return XMLNode(_n).getInnerText(); } -static LPCTSTR xmlapiGetAttrValue( HXML _n, LPCTSTR attrName ) +static LPCTSTR xmlapiGetAttrValue(HXML _n, LPCTSTR attrName) { - return XMLNode(_n).getAttribute( attrName ); + return XMLNode(_n).getAttribute(attrName); } -static void xmlapiSetText( HXML _n, LPCTSTR _text ) +static void xmlapiSetText(HXML _n, LPCTSTR _text) { - XMLNode(_n).updateText( _text ); + XMLNode(_n).updateText(_text); } -static LPTSTR xmlapiToString( HXML _n, int* datalen ) +static LPTSTR xmlapiToString(HXML _n, int* datalen) { - return XMLNode(_n).createXMLString( 0, datalen ); + return XMLNode(_n).createXMLString(0, datalen); } -static void xmlapiAddAttr( HXML _n, LPCTSTR attrName, LPCTSTR attrValue ) +static void xmlapiAddAttr(HXML _n, LPCTSTR attrName, LPCTSTR attrValue) { - if ( attrName != NULL && attrValue != NULL ) - XMLNode(_n).addAttribute( attrName, attrValue ); + if (attrName != NULL && attrValue != NULL) + XMLNode(_n).addAttribute(attrName, attrValue); } -static void xmlapiAddAttrInt( HXML _n, LPCTSTR attrName, int attrValue ) +static void xmlapiAddAttrInt(HXML _n, LPCTSTR attrName, int attrValue) { TCHAR buf[40]; - _itot( attrValue, buf, 10 ); - XMLNode(_n).addAttribute( attrName, buf ); + _itot(attrValue, buf, 10); + XMLNode(_n).addAttribute(attrName, buf); } -static void xmlapiFree( void* p ) +static void xmlapiFree(void* p) { - free( p ); + free(p); } // XML API v2 methods -static int xmlapiGetTextCount( HXML _n ) +static int xmlapiGetTextCount(HXML _n) { return XMLNode(_n).nText(); } -static LPCTSTR xmlapiGetTextByIndex( HXML _n, int i ) +static LPCTSTR xmlapiGetTextByIndex(HXML _n, int i) { - return XMLNode(_n).getText( i ); + return XMLNode(_n).getText(i); } -static void xmlapiSetTextByIndex( HXML _n, int i, LPCTSTR value ) +static void xmlapiSetTextByIndex(HXML _n, int i, LPCTSTR value) { - XMLNode(_n).updateText( value, i ); + XMLNode(_n).updateText(value, i); } -static void xmlapiAddText( HXML _n, LPCTSTR value, XML_ELEMENT_POS pos ) +static void xmlapiAddText(HXML _n, LPCTSTR value, XML_ELEMENT_POS pos) { - XMLNode(_n).addText( value, ( XMLElementPosition )pos ); + XMLNode(_n).addText(value, (XMLElementPosition)pos); } -static LPTSTR xmlapiToStringWithFormatting( HXML _n, int* datalen ) +static LPTSTR xmlapiToStringWithFormatting(HXML _n, int* datalen) { - return XMLNode(_n).createXMLString( 1, datalen ); + return XMLNode(_n).createXMLString(1, datalen); } -static int xmlapiGetClearCount( HXML _n ) +static int xmlapiGetClearCount(HXML _n) { return XMLNode(_n).nClear(); } -static LPCTSTR xmlapiGetClear( HXML _n, int i, LPCTSTR *openTag, LPCTSTR *closeTag ) +static LPCTSTR xmlapiGetClear(HXML _n, int i, LPCTSTR *openTag, LPCTSTR *closeTag) { - XMLClear c = XMLNode(_n).getClear( i ); - if ( openTag ) + XMLClear c = XMLNode(_n).getClear(i); + if (openTag) *openTag = c.lpszOpenTag; - if ( closeTag ) + if (closeTag) *closeTag = c.lpszCloseTag; return c.lpszValue; } -static void xmlapiAddClear( HXML _n, LPCTSTR lpszValue, LPCTSTR openTag, LPCTSTR closeTag, XML_ELEMENT_POS pos ) +static void xmlapiAddClear(HXML _n, LPCTSTR lpszValue, LPCTSTR openTag, LPCTSTR closeTag, XML_ELEMENT_POS pos) { - XMLNode(_n).addClear( lpszValue, openTag, closeTag, ( XMLElementPosition )pos ); + XMLNode(_n).addClear(lpszValue, openTag, closeTag, (XMLElementPosition)pos); } -static void xmlapiSetClear( HXML _n, int i, LPCTSTR lpszValue ) +static void xmlapiSetClear(HXML _n, int i, LPCTSTR lpszValue) { - XMLNode(_n).updateClear( lpszValue, i ); + XMLNode(_n).updateClear(lpszValue, i); } -static int xmlapiGetElement( HXML _n, XML_ELEMENT_POS pos, XML_ELEMENT_TYPE *type, HXML *child, LPCTSTR *value, LPCTSTR *name, LPCTSTR *openTag, LPCTSTR *closeTag ) +static int xmlapiGetElement(HXML _n, XML_ELEMENT_POS pos, XML_ELEMENT_TYPE *type, HXML *child, LPCTSTR *value, LPCTSTR *name, LPCTSTR *openTag, LPCTSTR *closeTag) { // reset all values - if ( child ) + if (child) *child = NULL; - if ( value ) + if (value) *value = NULL; - if ( name ) + if (name) *name = NULL; - if ( openTag ) + if (openTag) *openTag = NULL; - if ( closeTag ) + if (closeTag) *closeTag = NULL; if ( !type || pos >= XMLNode(_n).nElement()) return false; - XMLNodeContents c( XMLNode(_n).enumContents(( XMLElementPosition )pos )); - switch ( c.etype ) { + XMLNodeContents c(XMLNode(_n).enumContents((XMLElementPosition)pos)); + switch (c.etype) { case eNodeChild: { *type = XML_ELEM_TYPE_CHILD; - if ( child ) + if (child) *child = c.child; } break; case eNodeAttribute: { *type = XML_ELEM_TYPE_ATTRIBUTE; - if ( name ) + if (name) *name = c.attrib.lpszName; - if ( value ) + if (value) *value = c.attrib.lpszValue; } break; case eNodeText: { *type = XML_ELEM_TYPE_TEXT; - if ( value ) + if (value) *value = c.text; } break; case eNodeClear: { *type = XML_ELEM_TYPE_CLEAR; - if ( value ) + if (value) *value = c.clear.lpszValue; - if ( openTag ) + if (openTag) *openTag = c.clear.lpszOpenTag; - if ( closeTag ) + if (closeTag) *closeTag = c.clear.lpszCloseTag; } break; case eNodeNULL: @@ -280,100 +280,100 @@ static int xmlapiGetElement( HXML _n, XML_ELEMENT_POS pos, XML_ELEMENT_TYPE *typ return true; } -static int xmlapiGetElementCount( HXML _n ) +static int xmlapiGetElementCount(HXML _n) { return XMLNode(_n).nElement(); } -static char xmlapiIsDeclaration( HXML _n ) +static char xmlapiIsDeclaration(HXML _n) { return XMLNode(_n).isDeclaration(); } -static HXML xmlapiDeepCopy( HXML _n ) +static HXML xmlapiDeepCopy(HXML _n) { return XMLNode(_n).deepCopy().detach(); } -static HXML xmlapiAddChildEx( HXML _n, LPCTSTR name, char isDeclaration, XML_ELEMENT_POS pos ) +static HXML xmlapiAddChildEx(HXML _n, LPCTSTR name, char isDeclaration, XML_ELEMENT_POS pos) { - return XMLNode(_n).addChild( name, isDeclaration, ( XMLElementPosition )pos ); + return XMLNode(_n).addChild(name, isDeclaration, (XMLElementPosition)pos); } -static void xmlapiAddChildEx2( HXML _n, HXML parent, XML_ELEMENT_POS pos ) +static void xmlapiAddChildEx2(HXML _n, HXML parent, XML_ELEMENT_POS pos) { - XMLNode(_n).addChild( parent, ( XMLElementPosition )pos ); + XMLNode(_n).addChild(parent, (XMLElementPosition)pos); } -static void xmlapiSetAttrByIndex( HXML _n, int i, LPCTSTR value ) +static void xmlapiSetAttrByIndex(HXML _n, int i, LPCTSTR value) { - XMLNode(_n).updateAttribute( value, NULL, i ); + XMLNode(_n).updateAttribute(value, NULL, i); } -static void xmlapiSetAttrByName( HXML _n, LPCTSTR name, LPCTSTR value ) +static void xmlapiSetAttrByName(HXML _n, LPCTSTR name, LPCTSTR value) { - XMLNode(_n).updateAttribute( value, NULL, name ); + XMLNode(_n).updateAttribute(value, NULL, name); } -static void xmlapiDeleteNodeContent( HXML _n ) +static void xmlapiDeleteNodeContent(HXML _n) { XMLNode(_n).deleteNodeContent(); } -static void xmlapiDeleteAttrByIndex( HXML _n, int i ) +static void xmlapiDeleteAttrByIndex(HXML _n, int i) { - XMLNode(_n).deleteAttribute( i ); + XMLNode(_n).deleteAttribute(i); } -static void xmlapiDeleteAttrByName( HXML _n, LPCTSTR name ) +static void xmlapiDeleteAttrByName(HXML _n, LPCTSTR name) { - XMLNode(_n).deleteAttribute( name ); + XMLNode(_n).deleteAttribute(name); } -static void xmlapiDeleteText( HXML _n, int i ) +static void xmlapiDeleteText(HXML _n, int i) { - XMLNode(_n).deleteText( i ); + XMLNode(_n).deleteText(i); } -static void xmlapiDeleteClear( HXML _n, int i ) +static void xmlapiDeleteClear(HXML _n, int i) { - XMLNode(_n).deleteClear( i ); + XMLNode(_n).deleteClear(i); } -static XML_ELEMENT_POS xmlapiPositionOfText( HXML _n, int i ) +static XML_ELEMENT_POS xmlapiPositionOfText(HXML _n, int i) { - return ( XML_ELEMENT_POS )XMLNode(_n).positionOfText( i ); + return (XML_ELEMENT_POS)XMLNode(_n).positionOfText(i); } -static XML_ELEMENT_POS xmlapiPositionOfClear( HXML _n, int i ) +static XML_ELEMENT_POS xmlapiPositionOfClear(HXML _n, int i) { - return ( XML_ELEMENT_POS )XMLNode(_n).positionOfClear( i ); + return (XML_ELEMENT_POS)XMLNode(_n).positionOfClear(i); } -static XML_ELEMENT_POS xmlapiPositionOfChildByIndex( HXML _n, int i ) +static XML_ELEMENT_POS xmlapiPositionOfChildByIndex(HXML _n, int i) { - return ( XML_ELEMENT_POS )XMLNode(_n).positionOfChildNode( i ); + return (XML_ELEMENT_POS)XMLNode(_n).positionOfChildNode(i); } -static XML_ELEMENT_POS xmlapiPositionOfChildByNode( HXML _n, HXML child ) +static XML_ELEMENT_POS xmlapiPositionOfChildByNode(HXML _n, HXML child) { - return ( XML_ELEMENT_POS )XMLNode(_n).positionOfChildNode( child ); + return (XML_ELEMENT_POS)XMLNode(_n).positionOfChildNode(child); } -static XML_ELEMENT_POS xmlapiPositionOfChildByName( HXML _n, LPCTSTR name, int i ) +static XML_ELEMENT_POS xmlapiPositionOfChildByName(HXML _n, LPCTSTR name, int i) { - return ( XML_ELEMENT_POS )XMLNode(_n).positionOfChildNode( name, i ); + return (XML_ELEMENT_POS)XMLNode(_n).positionOfChildNode(name, i); } ///////////////////////////////////////////////////////////////////////////////////////// -static INT_PTR GetXmlApi( WPARAM, LPARAM lParam ) +static INT_PTR GetXmlApi(WPARAM, LPARAM lParam) { - XML_API* xi = ( XML_API* )lParam; - if ( xi == NULL ) + XML_API* xi = (XML_API*)lParam; + if (xi == NULL) return FALSE; - if ( xi->cbSize != XML_API_SIZEOF_V1 && xi->cbSize != sizeof(XML_API)) + if (xi->cbSize != XML_API_SIZEOF_V1 && xi->cbSize != sizeof(XML_API)) return FALSE; xi->createNode = xmlapiCreateNode; @@ -406,7 +406,7 @@ static INT_PTR GetXmlApi( WPARAM, LPARAM lParam ) xi->addAttr = xmlapiAddAttr; xi->addAttrInt = xmlapiAddAttrInt; - if ( xi->cbSize > XML_API_SIZEOF_V1 ) { + if (xi->cbSize > XML_API_SIZEOF_V1) { xi->isDeclaration = xmlapiIsDeclaration; xi->toStringWithFormatting = xmlapiToStringWithFormatting; xi->deepCopy = xmlapiDeepCopy; @@ -440,7 +440,7 @@ static INT_PTR GetXmlApi( WPARAM, LPARAM lParam ) return TRUE; } -void InitXmlApi( void ) +void InitXmlApi(void) { - CreateServiceFunction( MS_SYSTEM_GET_XI, GetXmlApi ); + CreateServiceFunction(MS_SYSTEM_GET_XI, GetXmlApi); } diff --git a/src/modules/xml/xmlParser.cpp b/src/modules/xml/xmlParser.cpp index c596d99c3f..32c81c88c8 100644 --- a/src/modules/xml/xmlParser.cpp +++ b/src/modules/xml/xmlParser.cpp @@ -65,7 +65,7 @@ void freeXMLString(XMLSTR t) {if(t)free(t);} static XMLNode::XMLCharEncoding characterEncoding=XMLNode::char_encoding_UTF8; static char guessWideCharChars=1, dropWhiteSpace=1, removeCommentsInMiddleOfText=1; -inline int mmin( const int t1, const int t2 ) { return t1 < t2 ? t1 : t2; } +inline int mmin(const int t1, const int t2) { return t1 < t2 ? t1 : t2; } // You can modify the initialization of the variable "XMLClearTags" below // to change the clearTags that are currently recognized by the library. @@ -92,9 +92,9 @@ static ALLXMLClearTag XMLClearTags[] = typedef struct { XMLCSTR s; int l; XMLCHAR c;} XMLCharacterEntity; static XMLCharacterEntity XMLEntities[] = { - { _CXML("&" ), 5, _CXML('&' )}, - { _CXML("<" ), 4, _CXML('<' )}, - { _CXML(">" ), 4, _CXML('>' )}, + { _CXML("&"), 5, _CXML('&')}, + { _CXML("<"), 4, _CXML('<')}, + { _CXML(">"), 4, _CXML('>')}, { _CXML("""), 6, _CXML('\"')}, { _CXML("'"), 6, _CXML('\'')}, { NULL , 0, '\0' } @@ -177,7 +177,7 @@ char myIsTextWideChar(const void *b, int len) // inspired by the Wine API: RtlIs if (stats>len/2) return TRUE; // Check for UNICODE NULL chars - for (i=0; ilpszName)||(!getChildNode().isDeclaration()))) + if (( !isDeclaration())&&((d->lpszName) || ( !getChildNode().isDeclaration()))) { - if (!fwrite(L"\n", sizeof(wchar_t)*40, 1, f)) + if ( !fwrite(L"\n", sizeof(wchar_t)*40, 1, f)) { fclose(f); return eXMLErrorCannotWriteFile; } } #else - if ((!isDeclaration())&&((d->lpszName)||(!getChildNode().isDeclaration()))) + if (( !isDeclaration())&&((d->lpszName) || ( !getChildNode().isDeclaration()))) { if (characterEncoding == char_encoding_UTF8) { // header so that windows recognize the file as UTF-8: unsigned char h[3]={0xEF, 0xBB, 0xBF}; - if (!fwrite(h, 3, 1, f)) + if ( !fwrite(h, 3, 1, f)) { fclose(f); return eXMLErrorCannotWriteFile; @@ -617,7 +617,7 @@ XMLError XMLNode::writeToFile(XMLCSTR filename, const char *encoding, char nForm encoding="utf-8"; } else if (characterEncoding == char_encoding_ShiftJIS) encoding="SHIFT-JIS"; - if (!encoding) encoding="ISO-8859-1"; + if ( !encoding) encoding="ISO-8859-1"; if (fprintf(f, "\n", encoding)<0) { fclose(f); @@ -628,7 +628,7 @@ XMLError XMLNode::writeToFile(XMLCSTR filename, const char *encoding, char nForm if (characterEncoding == char_encoding_UTF8) { unsigned char h[3]={0xEF, 0xBB, 0xBF}; - if (!fwrite(h, 3, 1, f)) + if ( !fwrite(h, 3, 1, f)) { fclose(f); return eXMLErrorCannotWriteFile; @@ -638,7 +638,7 @@ XMLError XMLNode::writeToFile(XMLCSTR filename, const char *encoding, char nForm #endif int i; XMLSTR t=createXMLString(nFormat, &i); - if (!fwrite(t, sizeof(XMLCHAR)*i, 1, f)) + if ( !fwrite(t, sizeof(XMLCHAR)*i, 1, f)) { free(t); fclose(f); @@ -729,7 +729,7 @@ ToXMLStringTool::~ToXMLStringTool() { freeBuffer(); } void ToXMLStringTool::freeBuffer() { if (buf) free(buf); buf=NULL; buflen=0; } XMLSTR ToXMLStringTool::toXML(XMLCSTR source) { - if (!source) + if ( !source) { if (buflen<1) { buflen=1; buf=(XMLSTR)malloc(sizeof(XMLCHAR)); } *buf=0; @@ -750,7 +750,7 @@ XMLSTR fromXMLString(XMLCSTR s, int lo, XML *pXML) // // in: string (s) and length (lo) of string // out: new allocated string converted from xml - if (!s) return NULL; + if ( !s) return NULL; int ll=0, j; XMLSTR d; @@ -763,7 +763,7 @@ XMLSTR fromXMLString(XMLCSTR s, int lo, XML *pXML) if ((lo>2)&&(s[1] == _CXML('#'))) { s+=2; lo-=2; - if ((*s == _CXML('X'))||(*s == _CXML('x'))) { s++; lo--; } + if ((*s == _CXML('X')) || (*s == _CXML('x'))) { s++; lo--; } while ((*s)&&(*s != _CXML(';'))&&((lo--)>0)) s++; if (*s != _CXML(';')) { @@ -779,7 +779,7 @@ XMLSTR fromXMLString(XMLCSTR s, int lo, XML *pXML) if ((lo>=entity->l)&&(xstrnicmp(s, entity->s, entity->l) == 0)) { s+=entity->l; lo-=entity->l; break; } entity++; } while (entity->s); - if (!entity->s) + if ( !entity->s) { pXML->error=eXMLErrorUnknownCharacterEntity; return NULL; @@ -805,7 +805,7 @@ XMLSTR fromXMLString(XMLCSTR s, int lo, XML *pXML) if (ss[1] == _CXML('#')) { ss+=2; j=0; - if ((*ss == _CXML('X'))||(*ss == _CXML('x'))) + if ((*ss == _CXML('X')) || (*ss == _CXML('x'))) { ss++; while (*ss != _CXML(';')) @@ -857,13 +857,13 @@ XMLSTR fromXMLString(XMLCSTR s, int lo, XML *pXML) #ifndef _XMLWIDECHAR if (characterEncoding != XMLNode::char_encoding_legacy) - Utf8Decode((XMLSTR)s, NULL ); + Utf8Decode((XMLSTR)s, NULL); #endif return (XMLSTR)s; } -#define XML_isSPACECHAR(ch) ((ch == _CXML('\n'))||(ch == _CXML(' '))||(ch == _CXML('\t'))||(ch == _CXML('\r'))) +#define XML_isSPACECHAR(ch) ((ch == _CXML('\n')) || (ch == _CXML(' ')) || (ch == _CXML('\t')) || (ch == _CXML('\r'))) // private: char myTagCompare(XMLCSTR cclose, XMLCSTR copen) @@ -871,15 +871,15 @@ char myTagCompare(XMLCSTR cclose, XMLCSTR copen) // return 0 if equals // return 1 if different { - if (!cclose) return 1; + if ( !cclose) return 1; int l=(int)xstrlen(cclose); if (xstrnicmp(cclose, copen, l) != 0) return 1; const XMLCHAR c=copen[l]; - if (XML_isSPACECHAR(c)|| - (c == _CXML('/' ))|| - (c == _CXML('<' ))|| - (c == _CXML('>' ))|| - (c == _CXML('=' ))) return 0; + if (XML_isSPACECHAR(c) || + (c == _CXML('/')) || + (c == _CXML('<')) || + (c == _CXML('>')) || + (c == _CXML('='))) return 0; return 1; } @@ -965,7 +965,7 @@ static NextToken GetNextToken(XML *pXML, int *pcbToken, enum XMLTokenTypeTag *pT ALLXMLClearTag *ctag=XMLClearTags; do { - if (!xstrncmp(ctag->lpszOpen, result.pStr, ctag->openTagLen)) + if ( !xstrncmp(ctag->lpszOpen, result.pStr, ctag->openTagLen)) { result.pClr=ctag; pXML->nIndex+=ctag->openTagLen-1; @@ -1046,7 +1046,7 @@ static NextToken GetNextToken(XML *pXML, int *pcbToken, enum XMLTokenTypeTag *pT // If we found a short hand end tag then we need to exit the loop if (ch == _CXML('>')) { pXML->nIndex--; break; } - } else if ((ch == _CXML('<'))||(ch == _CXML('>'))||(ch == _CXML('='))) + } else if ((ch == _CXML('<')) || (ch == _CXML('>')) || (ch == _CXML('='))) { pXML->nIndex--; break; } @@ -1066,7 +1066,7 @@ static NextToken GetNextToken(XML *pXML, int *pcbToken, enum XMLTokenTypeTag *pT XMLCSTR XMLNode::updateName_WOSD(XMLSTR lpszName) { - if (!d) { free(lpszName); return NULL; } + if ( !d) { free(lpszName); return NULL; } if (d->lpszName&&(lpszName != d->lpszName)) free((void*)d->lpszName); d->lpszName=lpszName; return lpszName; @@ -1099,9 +1099,9 @@ XMLNode::XMLNode(XMLNodeData *pParent, XMLSTR lpszName, char isDeclaration) updateName_WOSD(lpszName); d->lpszNS = NULL; - if ( lpszName && pParent && pParent->lpszName && !pParent->isDeclaration) { - TCHAR* p = _tcschr( lpszName, ':' ); - if ( p ) { + if (lpszName && pParent && pParent->lpszName && !pParent->isDeclaration) { + TCHAR* p = _tcschr(lpszName, ':'); + if (p) { *p = 0; d->lpszNS = d->lpszName; d->lpszName = p+1; @@ -1118,8 +1118,8 @@ static inline void myFree(void *p) { if (p) free(p); } static inline void *myRealloc(void *p, int newsize, int memInc, int sizeofElem) { if (p == NULL) { if (memInc) return malloc(memInc*sizeofElem); return malloc(sizeofElem); } - if ((memInc == 0)||((newsize%memInc) == 0)) p=realloc(p, (newsize+memInc)*sizeofElem); - // if (!p) + if ((memInc == 0) || ((newsize%memInc) == 0)) p=realloc(p, (newsize+memInc)*sizeofElem); + // if ( !p) // { // printf("XMLParser Error: Not enough memory! Aborting...\n"); exit(220); // } @@ -1157,7 +1157,7 @@ void *XMLNode::addToOrder(int memoryIncrease, int *_pos, int nc, void *p, int si d->pOrder=(int*)myRealloc(d->pOrder, n+1, memoryIncrease*3, sizeof(int)); int pos=*_pos, *o=d->pOrder; - if ((pos<0)||(pos>=n)) { *_pos=nc; o[n]=(int)((nc<<2)+xtype); return p; } + if ((pos<0) || (pos>=n)) { *_pos=nc; o[n]=(int)((nc<<2)+xtype); return p; } int i=pos; memmove(o+i+1, o+i, (n-i)*sizeof(int)); @@ -1177,7 +1177,7 @@ void *XMLNode::addToOrder(int memoryIncrease, int *_pos, int nc, void *p, int si // Add a child node to the given element. XMLNode XMLNode::addChild_priv(int memoryIncrease, XMLSTR lpszName, char isDeclaration, int pos) { - if (!lpszName) return emptyXMLNode; + if ( !lpszName) return emptyXMLNode; d->pChild=(XMLNode*)addToOrder(memoryIncrease, &pos, d->nChild, d->pChild, sizeof(XMLNode), eNodeChild); d->pChild[pos].d=NULL; d->pChild[pos]=XMLNode(d, lpszName, isDeclaration); @@ -1188,8 +1188,8 @@ XMLNode XMLNode::addChild_priv(int memoryIncrease, XMLSTR lpszName, char isDecla // Add an attribute to an element. XMLAttribute *XMLNode::addAttribute_priv(int memoryIncrease, XMLSTR lpszName, XMLSTR lpszValuev) { - if (!lpszName) return &emptyXMLAttribute; - if (!d) { myFree(lpszName); myFree(lpszValuev); return &emptyXMLAttribute; } + if ( !lpszName) return &emptyXMLAttribute; + if ( !d) { myFree(lpszName); myFree(lpszValuev); return &emptyXMLAttribute; } int nc=d->nAttribute; d->pAttribute=(XMLAttribute*)myRealloc(d->pAttribute, (nc+1), memoryIncrease, sizeof(XMLAttribute)); XMLAttribute *pAttr=d->pAttribute+nc; @@ -1197,9 +1197,9 @@ XMLAttribute *XMLNode::addAttribute_priv(int memoryIncrease, XMLSTR lpszName, XM pAttr->lpszValue = lpszValuev; d->nAttribute++; - TCHAR* p = _tcschr( lpszName, ':' ); - if ( p ) - if ( !lstrcmp( p+1, d->lpszNS ) || ( d->pParent && !lstrcmp( p+1, d->pParent->lpszNS ))) + TCHAR* p = _tcschr(lpszName, ':'); + if (p) + if ( !lstrcmp(p+1, d->lpszNS) || (d->pParent && !lstrcmp(p+1, d->pParent->lpszNS))) *p = 0; return pAttr; @@ -1208,8 +1208,8 @@ XMLAttribute *XMLNode::addAttribute_priv(int memoryIncrease, XMLSTR lpszName, XM // Add text to the element. XMLCSTR XMLNode::addText_priv(int memoryIncrease, XMLSTR lpszValue, int pos) { - if (!lpszValue) return NULL; - if (!d) { myFree(lpszValue); return NULL; } + if ( !lpszValue) return NULL; + if ( !d) { myFree(lpszValue); return NULL; } invalidateInnerText(); d->pText=(XMLCSTR*)addToOrder(memoryIncrease, &pos, d->nText, d->pText, sizeof(XMLSTR), eNodeText); d->pText[pos]=lpszValue; @@ -1220,14 +1220,14 @@ XMLCSTR XMLNode::addText_priv(int memoryIncrease, XMLSTR lpszValue, int pos) // Add clear (unformatted) text to the element. XMLClear *XMLNode::addClear_priv(int memoryIncrease, XMLSTR lpszValue, XMLCSTR lpszOpen, XMLCSTR lpszClose, int pos) { - if (!lpszValue) return &emptyXMLClear; - if (!d) { myFree(lpszValue); return &emptyXMLClear; } + if ( !lpszValue) return &emptyXMLClear; + if ( !d) { myFree(lpszValue); return &emptyXMLClear; } invalidateInnerText(); d->pClear=(XMLClear *)addToOrder(memoryIncrease, &pos, d->nClear, d->pClear, sizeof(XMLClear), eNodeClear); XMLClear *pNewClear=d->pClear+pos; pNewClear->lpszValue = lpszValue; - if (!lpszOpen) lpszOpen=XMLClearTags->lpszOpen; - if (!lpszClose) lpszClose=XMLClearTags->lpszClose; + if ( !lpszOpen) lpszOpen=XMLClearTags->lpszOpen; + if ( !lpszClose) lpszClose=XMLClearTags->lpszClose; pNewClear->lpszOpenTag = lpszOpen; pNewClear->lpszCloseTag = lpszClose; d->nClear++; @@ -1292,14 +1292,14 @@ char XMLNode::maybeAddTxT(void *pa, XMLCSTR tokenPStr) { XML *pXML=(XML *)pa; XMLCSTR lpszText=pXML->lpszText; - if (!lpszText) return 0; + if ( !lpszText) return 0; if (dropWhiteSpace) while (XML_isSPACECHAR(*lpszText)&&(lpszText != tokenPStr)) lpszText++; int cbText = (int)(tokenPStr - lpszText); - if (!cbText) { pXML->lpszText=NULL; return 0; } + if ( !cbText) { pXML->lpszText=NULL; return 0; } if (dropWhiteSpace) { cbText--; while ((cbText)&&XML_isSPACECHAR(lpszText[cbText])) cbText--; cbText++; } - if (!cbText) { pXML->lpszText=NULL; return 0; } + if ( !cbText) { pXML->lpszText=NULL; return 0; } XMLSTR lpt=fromXMLString(lpszText, cbText, pXML); - if (!lpt) return 1; + if ( !lpt) return 1; pXML->lpszText=NULL; if (removeCommentsInMiddleOfText && d->nText && d->nClear) { @@ -1316,7 +1316,7 @@ char XMLNode::maybeAddTxT(void *pa, XMLCSTR tokenPStr) n=xstrlen(d->pText[i]); int n2=xstrlen(lpt)+1; d->pText[i]=(XMLSTR)realloc((void*)d->pText[i], (n+n2)*sizeof(XMLCHAR)); - if (!d->pText[i]) return 1; + if ( !d->pText[i]) return 1; memcpy((void*)(d->pText[i]+n), lpt, n2*sizeof(XMLCHAR)); free(lpt); return 0; @@ -1422,13 +1422,13 @@ int XMLNode::ParseXMLElement(void *pa) // the current one and recurse pNew = addChild_priv(MEMORYINCREASE, stringDup(token.pStr, cbToken), nDeclaration, -1); - while (!pNew.isEmpty()) + while ( !pNew.isEmpty()) { // Callself to process the new node. If we return // FALSE this means we dont have any more // processing to do... - if (!pNew.ParseXMLElement(pXML)) return FALSE; + if ( !pNew.ParseXMLElement(pXML)) return FALSE; else { // If the call to recurse this function @@ -1441,7 +1441,7 @@ int XMLNode::ParseXMLElement(void *pa) { // If we are back at the root node then we // have an unmatched end tag - if (!d->lpszName) + if ( !d->lpszName) { pXML->error=eXMLErrorUnmatchedEndTag; return FALSE; @@ -1517,7 +1517,7 @@ int XMLNode::ParseXMLElement(void *pa) // We need to return to the previous caller. If the name // of the tag cannot be found we need to keep returning to // caller until we find a match - if (!d->lpszNS) { + if ( !d->lpszNS) { if (myTagCompare(d->lpszName, lpszTemp) != 0) #ifdef STRICT_PARSING { @@ -1537,8 +1537,8 @@ LBL_Error: #endif } else { - const TCHAR* p = _tcschr( lpszTemp, ':' ); - if ( !p ) + const TCHAR* p = _tcschr(lpszTemp, ':'); + if ( !p) goto LBL_Error; if (myTagCompare(d->lpszName, p+1) != 0) @@ -1707,7 +1707,7 @@ LBL_Error: if (attrVal) { attrVal=fromXMLString(attrVal, cbToken, pXML); - if (!attrVal) return FALSE; + if ( !attrVal) return FALSE; } addAttribute_priv(MEMORYINCREASE, stringDup(lpszTemp, cbTemp), attrVal); } @@ -1735,7 +1735,7 @@ LBL_Error: // If we failed to obtain the next token else { - if ((!d->isDeclaration)&&(d->pParent)) + if (( !d->isDeclaration)&&(d->pParent)) { #ifdef STRICT_PARSING pXML->error=eXMLErrorUnmatchedEndTag; @@ -1776,7 +1776,7 @@ static void CountLinesAndColumns(XMLCSTR lpXML, int nUpto, XMLResults *pResults) // Parse XML and return the root element. XMLNode XMLNode::parseString(XMLCSTR lpszXML, XMLCSTR tag, XMLResults *pResults) { - if (!lpszXML) + if ( !lpszXML) { if (pResults) { @@ -1793,14 +1793,14 @@ XMLNode XMLNode::parseString(XMLCSTR lpszXML, XMLCSTR tag, XMLResults *pResults) // Create header element xnode.ParseXMLElement(&xml); enum XMLError error = xml.error; - if (!xnode.nChildNode()) error=eXMLErrorNoXMLTagFound; + if ( !xnode.nChildNode()) error=eXMLErrorNoXMLTagFound; if ((xnode.nChildNode() == 1)&&(xnode.nElement() == 1)) xnode=xnode.getChildNode(); // skip the empty node // If no error occurred - if ((error == eXMLErrorNone)||(error == eXMLErrorMissingEndTag)||(error == eXMLErrorNoXMLTagFound)) + if ((error == eXMLErrorNone) || (error == eXMLErrorMissingEndTag) || (error == eXMLErrorNoXMLTagFound)) { XMLCSTR name=xnode.getName(); - if (tag&&(*tag)&&((!name)||(xstricmp(name, tag)))) + if (tag&&(*tag)&&(( !name) || (xstricmp(name, tag)))) { xnode=xnode.getChildNode(tag); if (xnode.isEmpty()) @@ -1847,7 +1847,7 @@ XMLNode XMLNode::parseFile(XMLCSTR filename, XMLCSTR tag, XMLResults *pResults) if (f == NULL) { if (pResults) pResults->error=eXMLErrorFileNotFound; return emptyXMLNode; } fseek(f, 0, SEEK_END); int l=(int)ftell(f), headerSz=0; - if (!l) { if (pResults) pResults->error=eXMLErrorEmpty; fclose(f); return emptyXMLNode; } + if ( !l) { if (pResults) pResults->error=eXMLErrorEmpty; fclose(f); return emptyXMLNode; } fseek(f, 0, SEEK_SET); unsigned char *buf=(unsigned char*)malloc(l+4); l=(int)fread(buf, 1, l, f); @@ -1856,12 +1856,12 @@ XMLNode XMLNode::parseFile(XMLCSTR filename, XMLCSTR tag, XMLResults *pResults) #ifdef _XMLWIDECHAR if (guessWideCharChars) { - if (!myIsTextWideChar(buf, l)) + if ( !myIsTextWideChar(buf, l)) { XMLNode::XMLCharEncoding ce=XMLNode::char_encoding_legacy; if ((buf[0] == 0xef)&&(buf[1] == 0xbb)&&(buf[2] == 0xbf)) { headerSz=3; ce=XMLNode::char_encoding_UTF8; } XMLSTR b2=myMultiByteToWideChar((const char*)(buf+headerSz), ce); - if (!b2) + if ( !b2) { // todo: unable to convert } @@ -1898,7 +1898,7 @@ XMLNode XMLNode::parseFile(XMLCSTR filename, XMLCSTR tag, XMLResults *pResults) } #endif - if (!buf) { if (pResults) pResults->error=eXMLErrorCharConversionError; return emptyXMLNode; } + if ( !buf) { if (pResults) pResults->error=eXMLErrorCharConversionError; return emptyXMLNode; } XMLNode x=parseString((XMLSTR)(buf+headerSz), tag, pResults); free(buf); return x; @@ -1919,7 +1919,7 @@ int XMLNode::CreateXMLStringR(XMLNodeData *pEntry, XMLSTR lpszMarker, int nForma int nChildFormat=-1; int nElementI=pEntry->nChild+pEntry->nText+pEntry->nClear; int i, j; - if ((nFormat>=0)&&(nElementI == 1)&&(pEntry->nText == 1)&&(!pEntry->isDeclaration)) nFormat=-2; + if ((nFormat>=0)&&(nElementI == 1)&&(pEntry->nText == 1)&&( !pEntry->isDeclaration)) nFormat=-2; assert(pEntry); @@ -2006,7 +2006,7 @@ int XMLNode::CreateXMLStringR(XMLNodeData *pEntry, XMLSTR lpszMarker, int nForma // determine the number of spaces used for prefixes. if (nFormat != -1) { - if (cbElement&&(!pEntry->isDeclaration)) nChildFormat=nFormat+1; + if (cbElement&&( !pEntry->isDeclaration)) nChildFormat=nFormat+1; else nChildFormat=nFormat; } @@ -2101,7 +2101,7 @@ int XMLNode::CreateXMLStringR(XMLNodeData *pEntry, XMLSTR lpszMarker, int nForma } } - if ((cbElement)&&(!pEntry->isDeclaration)) + if ((cbElement)&&( !pEntry->isDeclaration)) { // If we have child entries we need to use long XML notation for // closing the element - "blah blah blah" @@ -2164,13 +2164,13 @@ int XMLNode::CreateXMLStringR(XMLNodeData *pEntry, XMLSTR lpszMarker, int nForma // this with free(). XMLSTR XMLNode::createXMLString(int nFormat, int *pnSize) const { - if (!d) { if (pnSize) *pnSize=0; return NULL; } + if ( !d) { if (pnSize) *pnSize=0; return NULL; } XMLSTR lpszResult = NULL; int cbStr; // Recursively Calculate the size of the XML string - if (!dropWhiteSpace) nFormat=0; + if ( !dropWhiteSpace) nFormat=0; nFormat = nFormat ? 0 : -1; cbStr = CreateXMLStringR(d, 0, nFormat); // Alllocate memory for the XML string + the NULL terminator and @@ -2195,20 +2195,20 @@ int XMLNode::detachFromParent(XMLNodeData *d) XMLNode::~XMLNode() { - if (!d) return; + if ( !d) return; d->ref_count--; emptyTheNode(0); } void XMLNode::deleteNodeContent() { - if (!d) return; + if ( !d) return; if (d->pParent) { detachFromParent(d); d->pParent=NULL; d->ref_count--; } emptyTheNode(1); } void XMLNode::emptyTheNode(char force) { XMLNodeData *dd=d; // warning: must stay this way! - if ((dd->ref_count == 0)||force) + if ((dd->ref_count == 0) || force) { if (d->pParent) detachFromParent(d); int i; @@ -2249,12 +2249,12 @@ void XMLNode::emptyTheNode(char force) } void XMLNode::invalidateInnerText() { - if (!d) return; + if ( !d) return; myFree(d->pInnerText); d->pInnerText= NULL; } -XMLNode& XMLNode::operator=( const XMLNode& A ) +XMLNode& XMLNode::operator=(const XMLNode& A) { // shallow copy if (this != &A) @@ -2275,7 +2275,7 @@ XMLNode::XMLNode(const XMLNode &A) XMLNode XMLNode::deepCopy() const { - if (!d) return XMLNode::emptyXMLNode; + if ( !d) return XMLNode::emptyXMLNode; XMLNode x(NULL, stringDup(d->lpszName), d->isDeclaration); XMLNodeData *p=x.d; int n=d->nAttribute; @@ -2326,8 +2326,8 @@ XMLNode XMLNode::deepCopy() const XMLNode XMLNode::addChild(XMLNode childNode, int pos) { XMLNodeData *dc=childNode.d; - if ((!dc)||(!d)) return childNode; - if (!dc->lpszName) + if (( !dc) || ( !d)) return childNode; + if ( !dc->lpszName) { // this is a root node: todo: correct fix int j=pos; @@ -2350,7 +2350,7 @@ XMLNode XMLNode::addChild(XMLNode childNode, int pos) void XMLNode::deleteAttribute(int i) { - if ((!d)||(i<0)||(i>=d->nAttribute)) return; + if (( !d) || (i<0) || (i>=d->nAttribute)) return; d->nAttribute--; XMLAttribute *p=d->pAttribute+i; free((void*)p->lpszName); @@ -2368,7 +2368,7 @@ void XMLNode::deleteAttribute(XMLCSTR lpszName) XMLAttribute *XMLNode::updateAttribute_WOSD(XMLSTR lpszNewValue, XMLSTR lpszNewName, int i) { - if (!d) { if (lpszNewValue) free(lpszNewValue); if (lpszNewName) free(lpszNewName); return NULL; } + if ( !d) { if (lpszNewValue) free(lpszNewValue); if (lpszNewName) free(lpszNewName); return NULL; } if (i>=d->nAttribute) { if (lpszNewName) return addAttribute_WOSD(lpszNewName, lpszNewValue); @@ -2401,9 +2401,9 @@ XMLAttribute *XMLNode::updateAttribute_WOSD(XMLSTR lpszNewValue, XMLSTR lpszNewN int XMLNode::indexText(XMLCSTR lpszValue) const { - if (!d) return -1; + if ( !d) return -1; int i, l=d->nText; - if (!lpszValue) { if (l) return 0; return -1; } + if ( !lpszValue) { if (l) return 0; return -1; } XMLCSTR *p=d->pText; for (i=0; i=d->nText)) return; + if (( !d) || (i<0) || (i>=d->nText)) return; invalidateInnerText(); d->nText--; XMLCSTR *p=d->pText+i; @@ -2424,7 +2424,7 @@ void XMLNode::deleteText(XMLCSTR lpszValue) { deleteText(indexText(lpszValue)); XMLCSTR XMLNode::updateText_WOSD(XMLSTR lpszNewValue, int i) { - if (!d) { if (lpszNewValue) free(lpszNewValue); return NULL; } + if ( !d) { if (lpszNewValue) free(lpszNewValue); return NULL; } if (i>=d->nText) return addText_WOSD(lpszNewValue); invalidateInnerText(); XMLCSTR *p=d->pText+i; @@ -2434,7 +2434,7 @@ XMLCSTR XMLNode::updateText_WOSD(XMLSTR lpszNewValue, int i) XMLCSTR XMLNode::updateText_WOSD(XMLSTR lpszNewValue, XMLCSTR lpszOldValue) { - if (!d) { if (lpszNewValue) free(lpszNewValue); return NULL; } + if ( !d) { if (lpszNewValue) free(lpszNewValue); return NULL; } int i=indexText(lpszOldValue); if (i>=0) return updateText_WOSD(lpszNewValue, i); return addText_WOSD(lpszNewValue); @@ -2442,7 +2442,7 @@ XMLCSTR XMLNode::updateText_WOSD(XMLSTR lpszNewValue, XMLCSTR lpszOldValue) void XMLNode::deleteClear(int i) { - if ((!d)||(i<0)||(i>=d->nClear)) return; + if (( !d) || (i<0) || (i>=d->nClear)) return; invalidateInnerText(); d->nClear--; XMLClear *p=d->pClear+i; @@ -2453,9 +2453,9 @@ void XMLNode::deleteClear(int i) int XMLNode::indexClear(XMLCSTR lpszValue) const { - if (!d) return -1; + if ( !d) return -1; int i, l=d->nClear; - if (!lpszValue) { if (l) return 0; return -1; } + if ( !lpszValue) { if (l) return 0; return -1; } XMLClear *p=d->pClear; for (i=0; ilpszValue); } XMLClear *XMLNode::updateClear_WOSD(XMLSTR lpszNewContent, int i) { - if (!d) { if (lpszNewContent) free(lpszNewContent); return NULL; } + if ( !d) { if (lpszNewContent) free(lpszNewContent); return NULL; } if (i>=d->nClear) return addClear_WOSD(lpszNewContent); invalidateInnerText(); XMLClear *p=d->pClear+i; @@ -2476,7 +2476,7 @@ XMLClear *XMLNode::updateClear_WOSD(XMLSTR lpszNewContent, int i) XMLClear *XMLNode::updateClear_WOSD(XMLSTR lpszNewContent, XMLCSTR lpszOldValue) { - if (!d) { if (lpszNewContent) free(lpszNewContent); return NULL; } + if ( !d) { if (lpszNewContent) free(lpszNewContent); return NULL; } int i=indexClear(lpszOldValue); if (i>=0) return updateClear_WOSD(lpszNewContent, i); return addClear_WOSD(lpszNewContent); @@ -2490,7 +2490,7 @@ XMLClear *XMLNode::updateClear_WOSD(XMLClear *newP, XMLClear *oldP) int XMLNode::nChildNode(XMLCSTR name) const { - if (!d) return 0; + if ( !d) return 0; int i, j=0, n=d->nChild; XMLNode *pc=d->pChild; for (i=0; inChild; if (j) i=*j; XMLNode *pc=d->pChild+i; for (; id->lpszName, name)) + if ( !xstricmp(pc->d->lpszName, name)) { if (j) *j=i+1; return *pc; @@ -2521,7 +2521,7 @@ XMLNode XMLNode::getChildNode(XMLCSTR name, int *j) const XMLNode XMLNode::getChildNode(XMLCSTR name, int j) const { - if (!d) return emptyXMLNode; + if ( !d) return emptyXMLNode; if (j>=0) { int i=0; @@ -2529,16 +2529,16 @@ XMLNode XMLNode::getChildNode(XMLCSTR name, int j) const return getChildNode(name, &i); } int i=d->nChild; - while (i--) if (!xstricmp(name, d->pChild[i].d->lpszName)) break; + while (i--) if ( !xstricmp(name, d->pChild[i].d->lpszName)) break; if (i<0) return emptyXMLNode; return getChildNode(i); } XMLNode XMLNode::getNextNode() const { - if (!d) return emptyXMLNode; + if ( !d) return emptyXMLNode; XMLNodeDataTag *par=d->pParent; - if (!par) return emptyXMLNode; + if ( !par) return emptyXMLNode; int i, n=par->nChild; for (i=0; i=d->nText ) i=d->nText-1; return findPosition(d, i, eNodeText ); } +XMLElementPosition XMLNode::positionOfText (int i) const { if (i>=d->nText) i=d->nText-1; return findPosition(d, i, eNodeText); } XMLElementPosition XMLNode::positionOfClear (int i) const { if (i>=d->nClear) i=d->nClear-1; return findPosition(d, i, eNodeClear); } XMLElementPosition XMLNode::positionOfChildNode(int i) const { if (i>=d->nChild) i=d->nChild-1; return findPosition(d, i, eNodeChild); } XMLElementPosition XMLNode::positionOfText (XMLCSTR lpszValue) const { return positionOfText (indexText (lpszValue)); } @@ -2588,7 +2588,7 @@ XMLElementPosition XMLNode::positionOfClear(XMLCSTR lpszValue) const { return po XMLElementPosition XMLNode::positionOfClear(XMLClear *a) const { if (a) return positionOfClear(a->lpszValue); return positionOfClear(); } XMLElementPosition XMLNode::positionOfChildNode(XMLNode x) const { - if ((!d)||(!x.d)) return -1; + if (( !d) || ( !x.d)) return -1; XMLNodeData *dd=x.d; XMLNode *pc=d->pChild; int i=d->nChild; @@ -2597,7 +2597,7 @@ XMLElementPosition XMLNode::positionOfChildNode(XMLNode x) const } XMLElementPosition XMLNode::positionOfChildNode(XMLCSTR name, int count) const { - if (!name) return positionOfChildNode(count); + if ( !name) return positionOfChildNode(count); int j=0; do { getChildNode(name, &j); if (j<0) return -1; } while (count--); return findPosition(d, j-1, eNodeChild); @@ -2612,7 +2612,7 @@ XMLNode XMLNode::getChildNodeWithAttribute(XMLCSTR name, XMLCSTR attributeName, do { x=getChildNode(name, &i); - if (!x.isEmpty()) + if ( !x.isEmpty()) { if (attributeValue) { @@ -2627,14 +2627,14 @@ XMLNode XMLNode::getChildNodeWithAttribute(XMLCSTR name, XMLCSTR attributeName, if (x.isAttributeSet(attributeName)) { if (k) *k=i; return x; } } } - } while (!x.isEmpty()); + } while ( !x.isEmpty()); return emptyXMLNode; } // Find an attribute on an node. XMLCSTR XMLNode::getAttribute(XMLCSTR lpszAttrib, int *j) const { - if (!d) return NULL; + if ( !d) return NULL; int i=0, n=d->nAttribute; if (j) i=*j; XMLAttribute *pAttr=d->pAttribute+i; @@ -2652,7 +2652,7 @@ XMLCSTR XMLNode::getAttribute(XMLCSTR lpszAttrib, int *j) const char XMLNode::isAttributeSet(XMLCSTR lpszAttrib) const { - if (!d) return FALSE; + if ( !d) return FALSE; int i, n=d->nAttribute; XMLAttribute *pAttr=d->pAttribute; for (i=0; i0) getAttribute(name, &i); return getAttribute(name, &i); @@ -2677,7 +2677,7 @@ XMLCSTR XMLNode::getAttribute(XMLCSTR name, int j) const XMLNodeContents XMLNode::enumContents(int i) const { XMLNodeContents c; - if (!d) { c.etype=eNodeNULL; return c; } + if ( !d) { c.etype=eNodeNULL; return c; } if (inAttribute) { c.etype=eNodeAttribute; @@ -2699,7 +2699,7 @@ XMLNodeContents XMLNode::enumContents(int i) const XMLCSTR XMLNode::getInnerText() const { - if (!d) return NULL; + if ( !d) return NULL; if (nText() <= 1 && nClear() == 0) return getText(); if (d->pInnerText) return d->pInnerText; @@ -2738,22 +2738,22 @@ XMLCSTR XMLNode::getInnerText() const return d->pInnerText = buf; } -XMLCSTR XMLNode::getName() const { if (!d) return NULL; return d->lpszName; } -int XMLNode::nText() const { if (!d) return 0; return d->nText; } -int XMLNode::nChildNode() const { if (!d) return 0; return d->nChild; } -int XMLNode::nAttribute() const { if (!d) return 0; return d->nAttribute; } -int XMLNode::nClear() const { if (!d) return 0; return d->nClear; } -int XMLNode::nElement() const { if (!d) return 0; return d->nAttribute+d->nChild+d->nText+d->nClear; } -XMLClear XMLNode::getClear (int i) const { if ((!d)||(i>=d->nClear )) return emptyXMLClear; return d->pClear[i]; } -XMLAttribute XMLNode::getAttribute (int i) const { if ((!d)||(i>=d->nAttribute)) return emptyXMLAttribute; return d->pAttribute[i]; } -XMLCSTR XMLNode::getAttributeName (int i) const { if ((!d)||(i>=d->nAttribute)) return NULL; return d->pAttribute[i].lpszName; } -XMLCSTR XMLNode::getAttributeValue(int i) const { if ((!d)||(i>=d->nAttribute)) return NULL; return d->pAttribute[i].lpszValue; } -XMLCSTR XMLNode::getText (int i) const { if ((!d)||(i>=d->nText )) return NULL; return d->pText[i]; } -XMLNode XMLNode::getChildNode (int i) const { if ((!d)||(i>=d->nChild )) return emptyXMLNode; return d->pChild[i]; } -XMLNode XMLNode::getParentNode ( ) const { if ((!d)||(!d->pParent )) return emptyXMLNode; return XMLNode(d->pParent); } -char XMLNode::isDeclaration ( ) const { if (!d) return 0; return d->isDeclaration; } -char XMLNode::isEmpty ( ) const { return (d == NULL); } -XMLNode XMLNode::emptyNode ( ) { return XMLNode::emptyXMLNode; } +XMLCSTR XMLNode::getName() const { if ( !d) return NULL; return d->lpszName; } +int XMLNode::nText() const { if ( !d) return 0; return d->nText; } +int XMLNode::nChildNode() const { if ( !d) return 0; return d->nChild; } +int XMLNode::nAttribute() const { if ( !d) return 0; return d->nAttribute; } +int XMLNode::nClear() const { if ( !d) return 0; return d->nClear; } +int XMLNode::nElement() const { if ( !d) return 0; return d->nAttribute+d->nChild+d->nText+d->nClear; } +XMLClear XMLNode::getClear (int i) const { if (( !d) || (i>=d->nClear)) return emptyXMLClear; return d->pClear[i]; } +XMLAttribute XMLNode::getAttribute (int i) const { if (( !d) || (i>=d->nAttribute)) return emptyXMLAttribute; return d->pAttribute[i]; } +XMLCSTR XMLNode::getAttributeName (int i) const { if (( !d) || (i>=d->nAttribute)) return NULL; return d->pAttribute[i].lpszName; } +XMLCSTR XMLNode::getAttributeValue(int i) const { if (( !d) || (i>=d->nAttribute)) return NULL; return d->pAttribute[i].lpszValue; } +XMLCSTR XMLNode::getText (int i) const { if (( !d) || (i>=d->nText)) return NULL; return d->pText[i]; } +XMLNode XMLNode::getChildNode (int i) const { if (( !d) || (i>=d->nChild)) return emptyXMLNode; return d->pChild[i]; } +XMLNode XMLNode::getParentNode () const { if (( !d) || ( !d->pParent)) return emptyXMLNode; return XMLNode(d->pParent); } +char XMLNode::isDeclaration () const { if ( !d) return 0; return d->isDeclaration; } +char XMLNode::isEmpty () const { return (d == NULL); } +XMLNode XMLNode::emptyNode () { return XMLNode::emptyXMLNode; } XMLNode XMLNode::addChild(XMLCSTR lpszName, char isDeclaration, XMLElementPosition pos) { return addChild_priv(0, stringDup(lpszName), isDeclaration, pos); } @@ -2833,7 +2833,7 @@ XMLNode::XMLCharEncoding XMLNode::guessCharEncoding(void *buf, int l, char useXM case 1: i++; break; case 0: i=l; } - if (!useXMLEncodingAttribute) return bestGuess; + if ( !useXMLEncodingAttribute) return bestGuess; // if encoding is specified and different from utf-8 than it's non-utf8 // otherwise it's utf-8 char bb[201]; @@ -2841,20 +2841,20 @@ XMLNode::XMLCharEncoding XMLNode::guessCharEncoding(void *buf, int l, char useXM memcpy(bb, buf, l); // copy buf into bb to be able to do "bb[l]=0" bb[l]=0; b=(unsigned char*)strstr(bb, "encoding"); - if (!b) return bestGuess; + if ( !b) return bestGuess; b+=8; while XML_isSPACECHAR(*b) b++; if (*b != '=') return bestGuess; b++; while XML_isSPACECHAR(*b) b++; if ((*b != '\'')&&(*b != '"')) return bestGuess; b++; while XML_isSPACECHAR(*b) b++; - if ((xstrnicmp((char*)b, "utf-8", 5) == 0)|| + if ((xstrnicmp((char*)b, "utf-8", 5) == 0) || (xstrnicmp((char*)b, "utf8", 4) == 0)) { if (bestGuess == char_encoding_legacy) return char_encoding_error; return char_encoding_UTF8; } - if ((xstrnicmp((char*)b, "shiftjis", 8) == 0)|| - (xstrnicmp((char*)b, "shift-jis", 9) == 0)|| + if ((xstrnicmp((char*)b, "shiftjis", 8) == 0) || + (xstrnicmp((char*)b, "shift-jis", 9) == 0) || (xstrnicmp((char*)b, "sjis", 4) == 0)) return char_encoding_ShiftJIS; if (xstrnicmp((char*)b, "GB2312", 6) == 0) return char_encoding_GB2312; @@ -2913,8 +2913,8 @@ XMLSTR XMLParserBase64Tool::encode(unsigned char *inbuf, unsigned int inlen, cha *(curr++)=base64EncodeTable[ j>>18 ]; *(curr++)=base64EncodeTable[(j>>12)&0x3f]; *(curr++)=base64EncodeTable[(j>> 6)&0x3f]; - *(curr++)=base64EncodeTable[(j )&0x3f]; - if (formatted) { if (!k) { *(curr++)=_CXML('\n'); k=18; } k--; } + *(curr++)=base64EncodeTable[(j)&0x3f]; + if (formatted) { if ( !k) { *(curr++)=_CXML('\n'); k=18; } k--; } } eLen=inlen-eLen*3; // 0 - 2. if (eLen == 1) @@ -2937,7 +2937,7 @@ XMLSTR XMLParserBase64Tool::encode(unsigned char *inbuf, unsigned int inlen, cha unsigned int XMLParserBase64Tool::decodeSize(XMLCSTR data, XMLError *xe) { - if (!data) return 0; + if ( !data) return 0; if (xe) *xe=eXMLErrorNone; int size=0; unsigned char c; @@ -2960,7 +2960,7 @@ unsigned int XMLParserBase64Tool::decodeSize(XMLCSTR data, XMLError *xe) unsigned char XMLParserBase64Tool::decode(XMLCSTR data, unsigned char *buf, int len, XMLError *xe) { - if (!data) return 0; + if ( !data) return 0; if (xe) *xe=eXMLErrorNone; int i=0, p=0; unsigned char d, c; @@ -2990,7 +2990,7 @@ unsigned char XMLParserBase64Tool::decode(XMLCSTR data, unsigned char *buf, int } BASE64DECODE_READ_NEXT_CHAR(d) - if ((d == 99)||(d == 96)) { if (xe) *xe=eXMLErrorBase64DecodeTruncatedData; return 1; } + if ((d == 99) || (d == 96)) { if (xe) *xe=eXMLErrorBase64DecodeTruncatedData; return 1; } if (p == (int)len) { if (xe) *xe=eXMLErrorBase64DecodeBufferTooSmall; return 0; } buf[p++]=(unsigned char)((c<<2)|((d>>4)&0x3)); @@ -3006,7 +3006,7 @@ unsigned char XMLParserBase64Tool::decode(XMLCSTR data, unsigned char *buf, int buf[p++]=(unsigned char)(((d<<4)&0xf0)|((c>>2)&0xf)); BASE64DECODE_READ_NEXT_CHAR(d) - if (d == 99 ) { if (xe) *xe=eXMLErrorBase64DecodeTruncatedData; return 1; } + if (d == 99) { if (xe) *xe=eXMLErrorBase64DecodeTruncatedData; return 1; } if (p == (int)len) { if (d == 96) return 2; @@ -3021,19 +3021,19 @@ unsigned char XMLParserBase64Tool::decode(XMLCSTR data, unsigned char *buf, int void XMLParserBase64Tool::alloc(int newsize) { - if ((!buf)&&(newsize)) { buf=malloc(newsize); buflen=newsize; return; } + if (( !buf)&&(newsize)) { buf=malloc(newsize); buflen=newsize; return; } if (newsize>buflen) { buf=realloc(buf, newsize); buflen=newsize; } } unsigned char *XMLParserBase64Tool::decode(XMLCSTR data, int *outlen, XMLError *xe) { if (xe) *xe=eXMLErrorNone; - if (!data) { *outlen=0; return (unsigned char*)""; } + if ( !data) { *outlen=0; return (unsigned char*)""; } unsigned int len=decodeSize(data, xe); if (outlen) *outlen=len; - if (!len) return NULL; + if ( !len) return NULL; alloc(len+1); - if(!decode(data, (unsigned char*)buf, len, xe)) { return NULL; } + if( !decode(data, (unsigned char*)buf, len, xe)) { return NULL; } return (unsigned char*)buf; } @@ -3041,16 +3041,16 @@ unsigned char *XMLParserBase64Tool::decode(XMLCSTR data, int *outlen, XMLError * // Helpers for external C APIs. // ////////////////////////////////////////////////////////// -XMLNode::XMLNode( HXML h ) : -d(( XMLNodeDataTag* )h ) +XMLNode::XMLNode(HXML h) : +d((XMLNodeDataTag*)h) { if (d) d->ref_count++; } -void XMLNode::attach( HXML h ) +void XMLNode::attach(HXML h) { - d = ( XMLNodeDataTag* )h; + d = (XMLNodeDataTag*)h; } HXML XMLNode::detach() diff --git a/src/modules/xml/xmlParser.h b/src/modules/xml/xmlParser.h index e973fcf712..a166801d7c 100644 --- a/src/modules/xml/xmlParser.h +++ b/src/modules/xml/xmlParser.h @@ -350,7 +350,7 @@ public: ~XMLNode(); XMLNode(const XMLNode &A); ///< to allow shallow/fast copy: - XMLNode& operator=( const XMLNode& A ); ///< to allow shallow/fast copy: + XMLNode& operator=(const XMLNode& A); ///< to allow shallow/fast copy: XMLNode(): d(NULL) {}; static XMLNode emptyXMLNode; @@ -358,8 +358,8 @@ public: static XMLAttribute emptyXMLAttribute; /** helpers for external C applications **/ - XMLNode( HXML h ); - void attach( HXML h ); + XMLNode(HXML h); + void attach(HXML h); HXML detach(); operator HXML() const { return (HXML)d; } -- cgit v1.2.3