77a78
> * Copyright (c) 2010-2013 Advanced Micro Devices, Inc.
94c95
< // to have "MessageBoxA" to display error messages for openFilHelper
---
> // to have "MessageBoxA" to display error messages for openFilHelper
104,105c105,110
< XMLCSTR XMLNode::getVersion() { return _CXML("v2.39"); }
< void freeXMLString(XMLSTR t){if(t)free(t);}
---
> XMLCSTR XMLNode::getVersion() {
> return _CXML("v2.39");
> }
> void freeXMLString(XMLSTR t) {
> if (t)free(t);
> }
110c115,117
< 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;
> }
117,123c124,133
< typedef struct { XMLCSTR lpszOpen; int openTagLen; XMLCSTR lpszClose;} ALLXMLClearTag;
< static ALLXMLClearTag XMLClearTags[] =
< {
< { _CXML("<![CDATA["),9, _CXML("]]>") },
< { _CXML("<!DOCTYPE"),9, _CXML(">") },
< { _CXML("<!--") ,4, _CXML("-->") },
< { _CXML("<PRE>") ,5, _CXML("</PRE>") },
---
> typedef struct {
> XMLCSTR lpszOpen;
> int openTagLen;
> XMLCSTR lpszClose;
> } ALLXMLClearTag;
> static ALLXMLClearTag XMLClearTags[] = {
> { _CXML("<![CDATA["), 9, _CXML("]]>") },
> { _CXML("<!DOCTYPE"), 9, _CXML(">") },
> { _CXML("<!--") , 4, _CXML("-->") },
> { _CXML("<PRE>") , 5, _CXML("</PRE>") },
125c135
< { NULL ,0, NULL }
---
> { NULL , 0, NULL }
132,134c142,147
< typedef struct { XMLCSTR s; int l; XMLCHAR c;} XMLCharacterEntity;
< static XMLCharacterEntity XMLEntities[] =
< {
---
> typedef struct {
> XMLCSTR s;
> int l;
> XMLCHAR c;
> } XMLCharacterEntity;
> static XMLCharacterEntity XMLEntities[] = {
150,170c163,198
< XMLCSTR XMLNode::getError(XMLError xerror)
< {
< switch (xerror)
< {
< case eXMLErrorNone: return _CXML("No error");
< case eXMLErrorMissingEndTag: return _CXML("Warning: Unmatched end tag");
< case eXMLErrorNoXMLTagFound: return _CXML("Warning: No XML tag found");
< case eXMLErrorEmpty: return _CXML("Error: No XML data");
< case eXMLErrorMissingTagName: return _CXML("Error: Missing start tag name");
< case eXMLErrorMissingEndTagName: return _CXML("Error: Missing end tag name");
< case eXMLErrorUnmatchedEndTag: return _CXML("Error: Unmatched end tag");
< case eXMLErrorUnmatchedEndClearTag: return _CXML("Error: Unmatched clear tag end");
< case eXMLErrorUnexpectedToken: return _CXML("Error: Unexpected token found");
< case eXMLErrorNoElements: return _CXML("Error: No elements found");
< case eXMLErrorFileNotFound: return _CXML("Error: File not found");
< case eXMLErrorFirstTagNotFound: return _CXML("Error: First Tag not found");
< case eXMLErrorUnknownCharacterEntity:return _CXML("Error: Unknown character entity");
< case eXMLErrorCharacterCodeAbove255: return _CXML("Error: Character code above 255 is forbidden in MultiByte char mode.");
< case eXMLErrorCharConversionError: return _CXML("Error: unable to convert between WideChar and MultiByte chars");
< case eXMLErrorCannotOpenWriteFile: return _CXML("Error: unable to open file for writing");
< case eXMLErrorCannotWriteFile: return _CXML("Error: cannot write into file");
---
> XMLCSTR XMLNode::getError(XMLError xerror) {
> switch (xerror) {
> case eXMLErrorNone:
> return _CXML("No error");
> case eXMLErrorMissingEndTag:
> return _CXML("Warning: Unmatched end tag");
> case eXMLErrorNoXMLTagFound:
> return _CXML("Warning: No XML tag found");
> case eXMLErrorEmpty:
> return _CXML("Error: No XML data");
> case eXMLErrorMissingTagName:
> return _CXML("Error: Missing start tag name");
> case eXMLErrorMissingEndTagName:
> return _CXML("Error: Missing end tag name");
> case eXMLErrorUnmatchedEndTag:
> return _CXML("Error: Unmatched end tag");
> case eXMLErrorUnmatchedEndClearTag:
> return _CXML("Error: Unmatched clear tag end");
> case eXMLErrorUnexpectedToken:
> return _CXML("Error: Unexpected token found");
> case eXMLErrorNoElements:
> return _CXML("Error: No elements found");
> case eXMLErrorFileNotFound:
> return _CXML("Error: File not found");
> case eXMLErrorFirstTagNotFound:
> return _CXML("Error: First Tag not found");
> case eXMLErrorUnknownCharacterEntity:
> return _CXML("Error: Unknown character entity");
> case eXMLErrorCharacterCodeAbove255:
> return _CXML("Error: Character code above 255 is forbidden in MultiByte char mode.");
> case eXMLErrorCharConversionError:
> return _CXML("Error: unable to convert between WideChar and MultiByte chars");
> case eXMLErrorCannotOpenWriteFile:
> return _CXML("Error: unable to open file for writing");
> case eXMLErrorCannotWriteFile:
> return _CXML("Error: cannot write into file");
172,175c200,207
< case eXMLErrorBase64DataSizeIsNotMultipleOf4: return _CXML("Warning: Base64-string length is not a multiple of 4");
< case eXMLErrorBase64DecodeTruncatedData: return _CXML("Warning: Base64-string is truncated");
< case eXMLErrorBase64DecodeIllegalCharacter: return _CXML("Error: Base64-string contains an illegal character");
< case eXMLErrorBase64DecodeBufferTooSmall: return _CXML("Error: Base64 decode output buffer is too small");
---
> case eXMLErrorBase64DataSizeIsNotMultipleOf4:
> return _CXML("Warning: Base64-string length is not a multiple of 4");
> case eXMLErrorBase64DecodeTruncatedData:
> return _CXML("Warning: Base64-string is truncated");
> case eXMLErrorBase64DecodeIllegalCharacter:
> return _CXML("Error: Base64-string contains an illegal character");
> case eXMLErrorBase64DecodeBufferTooSmall:
> return _CXML("Error: Base64 decode output buffer is too small");
190c222,224
< char myIsTextWideChar(const void *b, int len) { return FALSE; }
---
> char myIsTextWideChar(const void *b, int len) {
> return FALSE;
> }
192,194c226,228
< #if defined (UNDER_CE) || !defined(_XMLWINDOWS)
< char myIsTextWideChar(const void *b, int len) // inspired by the Wine API: RtlIsTextUnicode
< {
---
> #if defined (UNDER_CE) || !defined(_XMLWINDOWS)
> // inspired by the Wine API: RtlIsTextUnicode
> char myIsTextWideChar(const void *b, int len) {
196,197c230,231
< // for SPARC processors: wchar_t* buffers must always be alligned, otherwise it's a char* buffer.
< if ((((unsigned long)b)%sizeof(wchar_t))!=0) return FALSE;
---
> // for SPARC processors: wchar_t* buffers must always be alligned, otherwise it's a char* buffer.
> if ((((unsigned long)b)%sizeof(wchar_t))!=0) return FALSE;
199c233
< const wchar_t *s=(const wchar_t*)b;
---
> const wchar_t *s = (const wchar_t*)b;
201,202c235,236
< // buffer too small:
< if (len<(int)sizeof(wchar_t)) return FALSE;
---
> // buffer too small:
> if (len < (int)sizeof(wchar_t)) return FALSE;
204,205c238,239
< // odd length test
< if (len&1) return FALSE;
---
> // odd length test
> if (len&1) return FALSE;
207,208c241,242
< /* only checks the first 256 characters */
< len=mmin(256,len/sizeof(wchar_t));
---
> /* only checks the first 256 characters */
> len = mmin(256, len / sizeof(wchar_t));
210,212c244,246
< // Check for the special byte order:
< if (*((unsigned short*)s) == 0xFFFE) return TRUE; // IS_TEXT_UNICODE_REVERSE_SIGNATURE;
< if (*((unsigned short*)s) == 0xFEFF) return TRUE; // IS_TEXT_UNICODE_SIGNATURE
---
> // Check for the special byte order:
> if (*((unsigned short*)s) == 0xFFFE) return TRUE; // IS_TEXT_UNICODE_REVERSE_SIGNATURE;
> if (*((unsigned short*)s) == 0xFEFF) return TRUE; // IS_TEXT_UNICODE_SIGNATURE
214,217c248,251
< // checks for ASCII characters in the UNICODE stream
< int i,stats=0;
< for (i=0; i<len; i++) if (s[i]<=(unsigned short)255) stats++;
< if (stats>len/2) return TRUE;
---
> // checks for ASCII characters in the UNICODE stream
> int i, stats=0;
> for (i=0; i<len; i++) if (s[i]<=(unsigned short)255) stats++;
> if (stats>len/2) return TRUE;
219,220c253,254
< // Check for UNICODE NULL chars
< for (i=0; i<len; i++) if (!s[i]) return TRUE;
---
> // Check for UNICODE NULL chars
> for (i=0; i<len; i++) if (!s[i]) return TRUE;
222,226c256,261
< return FALSE;
< }
< #else
< char myIsTextWideChar(const void *b,int l) { return (char)IsTextUnicode((CONST LPVOID)b,l,NULL); };
< #endif
---
> return FALSE;
> }
> #else
> char myIsTextWideChar(const void *b, int l) {
> return (char)IsTextUnicode((CONST LPVOID)b, l, NULL);
> };
227a263
> #endif
231,290c267,307
< #ifdef _XMLWIDECHAR
< wchar_t *myMultiByteToWideChar(const char *s, XMLNode::XMLCharEncoding ce)
< {
< int i;
< if (ce==XMLNode::char_encoding_UTF8) i=(int)MultiByteToWideChar(CP_UTF8,0 ,s,-1,NULL,0);
< else i=(int)MultiByteToWideChar(CP_ACP ,MB_PRECOMPOSED,s,-1,NULL,0);
< if (i<0) return NULL;
< wchar_t *d=(wchar_t *)malloc((i+1)*sizeof(XMLCHAR));
< if (ce==XMLNode::char_encoding_UTF8) i=(int)MultiByteToWideChar(CP_UTF8,0 ,s,-1,d,i);
< else i=(int)MultiByteToWideChar(CP_ACP ,MB_PRECOMPOSED,s,-1,d,i);
< d[i]=0;
< return d;
< }
< static inline FILE *xfopen(XMLCSTR filename,XMLCSTR mode) { return _wfopen(filename,mode); }
< static inline int xstrlen(XMLCSTR c) { return (int)wcslen(c); }
< static inline int xstrnicmp(XMLCSTR c1, XMLCSTR c2, int l) { return _wcsnicmp(c1,c2,l);}
< static inline int xstrncmp(XMLCSTR c1, XMLCSTR c2, int l) { return wcsncmp(c1,c2,l);}
< static inline int xstricmp(XMLCSTR c1, XMLCSTR c2) { return _wcsicmp(c1,c2); }
< static inline XMLSTR xstrstr(XMLCSTR c1, XMLCSTR c2) { return (XMLSTR)wcsstr(c1,c2); }
< static inline XMLSTR xstrcpy(XMLSTR c1, XMLCSTR c2) { return (XMLSTR)wcscpy(c1,c2); }
< #else
< char *myWideCharToMultiByte(const wchar_t *s)
< {
< UINT codePage=CP_ACP; if (characterEncoding==XMLNode::char_encoding_UTF8) codePage=CP_UTF8;
< int i=(int)WideCharToMultiByte(codePage, // code page
< 0, // performance and mapping flags
< s, // wide-character string
< -1, // number of chars in string
< NULL, // buffer for new string
< 0, // size of buffer
< NULL, // default for unmappable chars
< NULL // set when default char used
< );
< if (i<0) return NULL;
< char *d=(char*)malloc(i+1);
< WideCharToMultiByte(codePage, // code page
< 0, // performance and mapping flags
< s, // wide-character string
< -1, // number of chars in string
< d, // buffer for new string
< i, // size of buffer
< NULL, // default for unmappable chars
< NULL // set when default char used
< );
< d[i]=0;
< return d;
< }
< static inline FILE *xfopen(XMLCSTR filename,XMLCSTR mode) { return fopen(filename,mode); }
< static inline int xstrlen(XMLCSTR c) { return (int)strlen(c); }
< #ifdef __BORLANDC__
< static inline int xstrnicmp(XMLCSTR c1, XMLCSTR c2, int l) { return strnicmp(c1,c2,l);}
< static inline int xstricmp(XMLCSTR c1, XMLCSTR c2) { return stricmp(c1,c2); }
< #else
< static inline int xstrnicmp(XMLCSTR c1, XMLCSTR c2, int l) { return _strnicmp(c1,c2,l);}
< static inline int xstricmp(XMLCSTR c1, XMLCSTR c2) { return _stricmp(c1,c2); }
< #endif
< static inline int xstrncmp(XMLCSTR c1, XMLCSTR c2, int l) { return strncmp(c1,c2,l);}
< static inline XMLSTR xstrstr(XMLCSTR c1, XMLCSTR c2) { return (XMLSTR)strstr(c1,c2); }
< static inline XMLSTR xstrcpy(XMLSTR c1, XMLCSTR c2) { return (XMLSTR)strcpy(c1,c2); }
< #endif
---
> #ifdef _XMLWIDECHAR
> wchar_t *myMultiByteToWideChar(const char *s, XMLNode::XMLCharEncoding ce) {
> int i;
> if (ce == XMLNode::char_encoding_UTF8) {
> i = (int)MultiByteToWideChar(CP_UTF8, 0, s, -1, NULL, 0);
> } else {
> i = (int)MultiByteToWideChar(CP_ACP , MB_PRECOMPOSED, s, -1, NULL, 0);
> }
> if (i < 0) {
> return NULL;
> }
> wchar_t *d = (wchar_t *)malloc((i + 1) * sizeof(XMLCHAR));
> if (ce == XMLNode::char_encoding_UTF8) {
> i = (int)MultiByteToWideChar(CP_UTF8, 0, s, -1, d, i);
> } else {
> i = (int)MultiByteToWideChar(CP_ACP , MB_PRECOMPOSED, s, -1, d, i);
> }
> d[i] = 0;
> return d;
> }
> static inline FILE *xfopen(XMLCSTR filename, XMLCSTR mode) {
> return _wfopen(filename, mode);
> }
> static inline int xstrlen(XMLCSTR c) {
> return (int)wcslen(c);
> }
> static inline int xstrnicmp(XMLCSTR c1, XMLCSTR c2, int l) {
> return _wcsnicmp(c1, c2, l);
> }
> static inline int xstrncmp(XMLCSTR c1, XMLCSTR c2, int l) {
> return wcsncmp(c1, c2, l);
> }
> static inline int xstricmp(XMLCSTR c1, XMLCSTR c2) {
> return _wcsicmp(c1, c2);
> }
> static inline XMLSTR xstrstr(XMLCSTR c1, XMLCSTR c2) {
> return (XMLSTR)wcsstr(c1, c2);
> }
> static inline XMLSTR xstrcpy(XMLSTR c1, XMLCSTR c2) {
> return (XMLSTR)wcscpy(c1, c2);
> }
291a309,366
> char *myWideCharToMultiByte(const wchar_t *s) {
> UINT codePage = CP_ACP;
> if (characterEncoding == XMLNode::char_encoding_UTF8) codePage = CP_UTF8;
> int i = (int)WideCharToMultiByte(codePage, // code page
> 0, // performance and mapping flags
> s, // wide-character string
> -1, // number of chars in string
> NULL, // buffer for new string
> 0, // size of buffer
> NULL, // default for unmappable chars
> NULL // set when default char used
> );
> if (i<0) return NULL;
> char *d=(char*)malloc(i+1);
> WideCharToMultiByte(codePage, // code page
> 0, // performance and mapping flags
> s, // wide-character string
> -1, // number of chars in string
> d, // buffer for new string
> i, // size of buffer
> NULL, // default for unmappable chars
> NULL // set when default char used
> );
> d[i] = 0;
> return d;
> }
> static inline FILE *xfopen(XMLCSTR filename, XMLCSTR mode) {
> return fopen(filename, mode);
> }
> static inline int xstrlen(XMLCSTR c) {
> return (int)strlen(c);
> }
> #ifdef __BORLANDC__
> static inline int xstrnicmp(XMLCSTR c1, XMLCSTR c2, int l) {
> return strnicmp(c1, c2, l);
> }
> static inline int xstricmp(XMLCSTR c1, XMLCSTR c2) {
> return stricmp(c1, c2);
> }
> #else
> static inline int xstrnicmp(XMLCSTR c1, XMLCSTR c2, int l) {
> return _strnicmp(c1, c2, l);
> }
> static inline int xstricmp(XMLCSTR c1, XMLCSTR c2) {
> return _stricmp(c1, c2);
> }
> #endif
> static inline int xstrncmp(XMLCSTR c1, XMLCSTR c2, int l) {
> return strncmp(c1, c2, l);
> }
> static inline XMLSTR xstrstr(XMLCSTR c1, XMLCSTR c2) {
> return (XMLSTR)strstr(c1, c2);
> }
> static inline XMLSTR xstrcpy(XMLSTR c1, XMLCSTR c2) {
> return (XMLSTR)strcpy(c1, c2);
> }
> #endif
> #else
293,351c368,381
< #ifdef XML_NO_WIDE_CHAR
< char *myWideCharToMultiByte(const wchar_t *s) { return NULL; }
< #else
< char *myWideCharToMultiByte(const wchar_t *s)
< {
< const wchar_t *ss=s;
< int i=(int)wcsrtombs(NULL,&ss,0,NULL);
< if (i<0) return NULL;
< char *d=(char *)malloc(i+1);
< wcsrtombs(d,&s,i,NULL);
< d[i]=0;
< return d;
< }
< #endif
< #ifdef _XMLWIDECHAR
< wchar_t *myMultiByteToWideChar(const char *s, XMLNode::XMLCharEncoding ce)
< {
< const char *ss=s;
< int i=(int)mbsrtowcs(NULL,&ss,0,NULL);
< if (i<0) return NULL;
< wchar_t *d=(wchar_t *)malloc((i+1)*sizeof(wchar_t));
< mbsrtowcs(d,&s,i,NULL);
< d[i]=0;
< return d;
< }
< int xstrlen(XMLCSTR c) { return wcslen(c); }
< #ifdef sun
< // for CC
< #include <widec.h>
< static inline int xstrnicmp(XMLCSTR c1, XMLCSTR c2, int l) { return wsncasecmp(c1,c2,l);}
< static inline int xstrncmp(XMLCSTR c1, XMLCSTR c2, int l) { return wsncmp(c1,c2,l);}
< static inline int xstricmp(XMLCSTR c1, XMLCSTR c2) { return wscasecmp(c1,c2); }
< #else
< // for gcc
< static inline int xstrnicmp(XMLCSTR c1, XMLCSTR c2, int l) { return wcsncasecmp(c1,c2,l);}
< static inline int xstrncmp(XMLCSTR c1, XMLCSTR c2, int l) { return wcsncmp(c1,c2,l);}
< static inline int xstricmp(XMLCSTR c1, XMLCSTR c2) { return wcscasecmp(c1,c2); }
< #endif
< static inline XMLSTR xstrstr(XMLCSTR c1, XMLCSTR c2) { return (XMLSTR)wcsstr(c1,c2); }
< static inline XMLSTR xstrcpy(XMLSTR c1, XMLCSTR c2) { return (XMLSTR)wcscpy(c1,c2); }
< static inline FILE *xfopen(XMLCSTR filename,XMLCSTR mode)
< {
< char *filenameAscii=myWideCharToMultiByte(filename);
< FILE *f;
< if (mode[0]==_CXML('r')) f=fopen(filenameAscii,"rb");
< else f=fopen(filenameAscii,"wb");
< free(filenameAscii);
< return f;
< }
< #else
< static inline FILE *xfopen(XMLCSTR filename,XMLCSTR mode) { return fopen(filename,mode); }
< static inline int xstrlen(XMLCSTR c) { return strlen(c); }
< static inline int xstrnicmp(XMLCSTR c1, XMLCSTR c2, int l) { return strncasecmp(c1,c2,l);}
< static inline int xstrncmp(XMLCSTR c1, XMLCSTR c2, int l) { return strncmp(c1,c2,l);}
< static inline int xstricmp(XMLCSTR c1, XMLCSTR c2) { return strcasecmp(c1,c2); }
< static inline XMLSTR xstrstr(XMLCSTR c1, XMLCSTR c2) { return (XMLSTR)strstr(c1,c2); }
< static inline XMLSTR xstrcpy(XMLSTR c1, XMLCSTR c2) { return (XMLSTR)strcpy(c1,c2); }
< #endif
< static inline int _strnicmp(const char *c1,const char *c2, int l) { return strncasecmp(c1,c2,l);}
---
> #ifdef XML_NO_WIDE_CHAR
> char *myWideCharToMultiByte(const wchar_t *s) {
> return NULL;
> }
> #else
> char *myWideCharToMultiByte(const wchar_t *s) {
> const wchar_t *ss = s;
> int i = (int)wcsrtombs(NULL, &ss, 0, NULL);
> if (i < 0) return NULL;
> char *d = (char *)malloc(i + 1);
> wcsrtombs(d, &s, i, NULL);
> d[i] = 0;
> return d;
> }
352a383,460
> #ifdef _XMLWIDECHAR
> wchar_t *myMultiByteToWideChar(const char *s, XMLNode::XMLCharEncoding ce) {
> const char *ss = s;
> int i = (int)mbsrtowcs(NULL, &ss, 0, NULL);
> if (i < 0) return NULL;
> wchar_t *d = (wchar_t *)malloc((i + 1) * sizeof(wchar_t));
> mbsrtowcs(d, &s, i, NULL);
> d[i] = 0;
> return d;
> }
> int xstrlen(XMLCSTR c) {
> return wcslen(c);
> }
> #ifdef sun
> // for CC
> #include <widec.h>
> static inline int xstrnicmp(XMLCSTR c1, XMLCSTR c2, int l) {
> return wsncasecmp(c1, c2, l);
> }
> static inline int xstrncmp(XMLCSTR c1, XMLCSTR c2, int l) {
> return wsncmp(c1, c2, l);
> }
> static inline int xstricmp(XMLCSTR c1, XMLCSTR c2) {
> return wscasecmp(c1, c2);
> }
> #else
> // for gcc
> static inline int xstrnicmp(XMLCSTR c1, XMLCSTR c2, int l) {
> return wcsncasecmp(c1, c2, l);
> }
> static inline int xstrncmp(XMLCSTR c1, XMLCSTR c2, int l) {
> return wcsncmp(c1, c2, l);
> }
> static inline int xstricmp(XMLCSTR c1, XMLCSTR c2) {
> return wcscasecmp(c1, c2);
> }
> #endif
> static inline XMLSTR xstrstr(XMLCSTR c1, XMLCSTR c2) {
> return (XMLSTR)wcsstr(c1, c2);
> }
> static inline XMLSTR xstrcpy(XMLSTR c1, XMLCSTR c2) {
> return (XMLSTR)wcscpy(c1, c2);
> }
> static inline FILE *xfopen(XMLCSTR filename, XMLCSTR mode) {
> char *filenameAscii = myWideCharToMultiByte(filename);
> FILE *f;
> if (mode[0] == _CXML('r')) f = fopen(filenameAscii, "rb");
> else f = fopen(filenameAscii, "wb");
> free(filenameAscii);
> return f;
> }
> #else
> static inline FILE *xfopen(XMLCSTR filename, XMLCSTR mode) {
> return fopen(filename, mode);
> }
> static inline int xstrlen(XMLCSTR c) {
> return strlen(c);
> }
> static inline int xstrnicmp(XMLCSTR c1, XMLCSTR c2, int l) {
> return strncasecmp(c1, c2, l);
> }
> static inline int xstrncmp(XMLCSTR c1, XMLCSTR c2, int l) {
> return strncmp(c1, c2, l);
> }
> static inline int xstricmp(XMLCSTR c1, XMLCSTR c2) {
> return strcasecmp(c1, c2);
> }
> static inline XMLSTR xstrstr(XMLCSTR c1, XMLCSTR c2) {
> return (XMLSTR)strstr(c1, c2);
> }
> static inline XMLSTR xstrcpy(XMLSTR c1, XMLCSTR c2) {
> return (XMLSTR)strcpy(c1, c2);
> }
> #endif
> static inline int _strnicmp(const char *c1, const char *c2, int l) {
> return strncasecmp(c1, c2, l);
> }
> #endif
362,382c470,487
< #ifdef _XMLWINDOWS
< // for Microsoft Visual Studio 6.0 and Microsoft Visual Studio .NET and Borland C++ Builder 6.0
< char xmltob(XMLCSTR t,int v){ if (t&&(*t)) return (char)_wtoi(t); return v; }
< int xmltoi(XMLCSTR t,int v){ if (t&&(*t)) return _wtoi(t); return v; }
< long xmltol(XMLCSTR t,long v){ if (t&&(*t)) return _wtol(t); return v; }
< double xmltof(XMLCSTR t,double v){ if (t&&(*t)) wscanf(t, "%f", &v); /*v=_wtof(t);*/ return v; }
< #else
< #ifdef sun
< // for CC
< #include <widec.h>
< char xmltob(XMLCSTR t,int v){ if (t) return (char)wstol(t,NULL,10); return v; }
< int xmltoi(XMLCSTR t,int v){ if (t) return (int)wstol(t,NULL,10); return v; }
< long xmltol(XMLCSTR t,long v){ if (t) return wstol(t,NULL,10); return v; }
< #else
< // for gcc
< char xmltob(XMLCSTR t,int v){ if (t) return (char)wcstol(t,NULL,10); return v; }
< int xmltoi(XMLCSTR t,int v){ if (t) return (int)wcstol(t,NULL,10); return v; }
< long xmltol(XMLCSTR t,long v){ if (t) return wcstol(t,NULL,10); return v; }
< #endif
< double xmltof(XMLCSTR t,double v){ if (t&&(*t)) wscanf(t, "%f", &v); /*v=_wtof(t);*/ return v; }
< #endif
---
> #ifdef _XMLWINDOWS
> // for Microsoft Visual Studio 6.0 and Microsoft Visual Studio .NET and Borland C++ Builder 6.0
> char xmltob(XMLCSTR t, int v) {
> if (t && (*t)) return (char)_wtoi(t);
> return v;
> }
> int xmltoi(XMLCSTR t, int v) {
> if (t && (*t)) return _wtoi(t);
> return v;
> }
> long xmltol(XMLCSTR t, long v) {
> if (t && (*t)) return _wtol(t);
> return v;
> }
> double xmltof(XMLCSTR t, double v) {
> if (t && (*t)) wscanf(t, "%f", &v); /*v=_wtof(t);*/
> return v;
> }
384,387c489,517
< char xmltob(XMLCSTR t,char v){ if (t&&(*t)) return (char)atoi(t); return v; }
< int xmltoi(XMLCSTR t,int v){ if (t&&(*t)) return atoi(t); return v; }
< long xmltol(XMLCSTR t,long v){ if (t&&(*t)) return atol(t); return v; }
< double xmltof(XMLCSTR t,double v){ if (t&&(*t)) return atof(t); return v; }
---
> #ifdef sun
> // for CC
> #include <widec.h>
> char xmltob(XMLCSTR t, int v) {
> if (t) return (char)wstol(t, NULL, 10);
> return v;
> }
> int xmltoi(XMLCSTR t, int v) {
> if (t) return (int)wstol(t, NULL, 10);
> return v;
> }
> long xmltol(XMLCSTR t, long v) {
> if (t) return wstol(t, NULL, 10);
> return v;
> }
> #else
> // for gcc
> char xmltob(XMLCSTR t, int v) {
> if (t) return (char)wcstol(t, NULL, 10);
> return v;
> }
> int xmltoi(XMLCSTR t, int v) {
> if (t) return (int)wcstol(t, NULL, 10);
> return v;
> }
> long xmltol(XMLCSTR t, long v) {
> if (t) return wcstol(t, NULL, 10);
> return v;
> }
389,390c519,549
< XMLCSTR xmltoa(XMLCSTR t,XMLCSTR v){ if (t) return t; return v; }
< XMLCHAR xmltoc(XMLCSTR t,XMLCHAR v){ if (t&&(*t)) return *t; return v; }
---
> double xmltof(XMLCSTR t, double v) {
> if (t && (*t)) wscanf(t, "%f", &v); /*v=_wtof(t);*/
> return v;
> }
> #endif
> #else
> char xmltob(XMLCSTR t, char v) {
> if (t && (*t)) return (char)atoi(t);
> return v;
> }
> int xmltoi(XMLCSTR t, int v) {
> if (t && (*t)) return atoi(t);
> return v;
> }
> long xmltol(XMLCSTR t, long v) {
> if (t && (*t)) return atol(t);
> return v;
> }
> double xmltof(XMLCSTR t, double v) {
> if (t && (*t)) return atof(t);
> return v;
> }
> #endif
> XMLCSTR xmltoa(XMLCSTR t, XMLCSTR v) {
> if (t) return t;
> return v;
> }
> XMLCHAR xmltoc(XMLCSTR t, XMLCHAR v) {
> if (t && (*t)) return *t;
> return v;
> }
398,399c557
< XMLNode XMLNode::openFileHelper(XMLCSTR filename, XMLCSTR tag)
< {
---
> XMLNode XMLNode::openFileHelper(XMLCSTR filename, XMLCSTR tag) {
402,404c560,561
< FILE *f=xfopen(filename,_CXML("rb"));
< if (f)
< {
---
> FILE *f = xfopen(filename, _CXML("rb"));
> if (f) {
406,407c563,565
< int l=(int)fread(bb,1,200,f);
< setGlobalOptions(guessCharEncoding(bb,l),guessWideCharChars,dropWhiteSpace,removeCommentsInMiddleOfText);
---
> int l = (int)fread(bb, 1, 200, f);
> setGlobalOptions(guessCharEncoding(bb, l), guessWideCharChars,
> dropWhiteSpace, removeCommentsInMiddleOfText);
413c571
< XMLNode xnode=XMLNode::parseFile(filename,tag,&pResults);
---
> XMLNode xnode = XMLNode::parseFile(filename, tag, &pResults);
416,417c574
< if (pResults.error != eXMLErrorNone)
< {
---
> if (pResults.error != eXMLErrorNone) {
419,420c576,582
< char message[2000],*s1=(char*)"",*s3=(char*)""; XMLCSTR s2=_CXML("");
< if (pResults.error==eXMLErrorFirstTagNotFound) { s1=(char*)"First Tag should be '"; s2=tag; s3=(char*)"'.\n"; }
---
> char message[2000], *s1 = (char*)"", *s3 = (char*)"";
> XMLCSTR s2 = _CXML("");
> if (pResults.error == eXMLErrorFirstTagNotFound) {
> s1 = (char*)"First Tag should be '";
> s2 = tag;
> s3 = (char*)"'.\n";
> }
423c585
< "XML Parsing error inside file '%S'.\n%S\nAt line %i, column %i.\n%s%S%s"
---
> "XML Parsing error inside file '%S'.\n%S\nAt line %i, column %i.\n%s%S%s"
425c587
< "XML Parsing error inside file '%s'.\n%s\nAt line %i, column %i.\n%s%s%s"
---
> "XML Parsing error inside file '%s'.\n%s\nAt line %i, column %i.\n%s%s%s"
427c589,590
< ,filename,XMLNode::getError(pResults.error),pResults.nLine,pResults.nColumn,s1,s2,s3);
---
> , filename, XMLNode::getError(pResults.error), pResults.nLine,
> pResults.nColumn, s1, s2, s3);
431c594,595
< MessageBoxA(NULL,message,"XML Parsing error",MB_OK|MB_ICONERROR|MB_TOPMOST);
---
> MessageBoxA(NULL, message, "XML Parsing error", MB_OK | MB_ICONERROR |
> MB_TOPMOST);
433c597
< printf("%s",message);
---
> printf("%s", message);
453,454c617
< static const char XML_utf8ByteTable[256] =
< {
---
> static const char XML_utf8ByteTable[256] = {
456,471c619,634
< 0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,// 0x00
< 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,// 0x10
< 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,// 0x20
< 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,// 0x30
< 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,// 0x40
< 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,// 0x50
< 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,// 0x60
< 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,// 0x70 End of ASCII range
< 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,// 0x80 0x80 to 0xc1 invalid
< 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,// 0x90
< 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,// 0xa0
< 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,// 0xb0
< 1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,// 0xc0 0xc2 to 0xdf 2 byte
< 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,// 0xd0
< 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,// 0xe0 0xe0 to 0xef 3 byte
< 4,4,4,4,4,1,1,1,1,1,1,1,1,1,1,1 // 0xf0 0xf0 to 0xf4 4 byte, 0xf5 and higher invalid
---
> 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,// 0x00
> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,// 0x10
> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,// 0x20
> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,// 0x30
> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,// 0x40
> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,// 0x50
> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,// 0x60
> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,// 0x70 End of ASCII range
> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,// 0x80 0x80 to 0xc1 invalid
> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,// 0x90
> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,// 0xa0
> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,// 0xb0
> 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,// 0xc0 0xc2 to 0xdf 2 byte
> 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,// 0xd0
> 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,// 0xe0 0xe0 to 0xef 3 byte
> 4, 4, 4, 4, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 // 0xf0 0xf0 to 0xf4 4 byte, 0xf5 and higher invalid
473,480c636,642
< static const char XML_legacyByteTable[256] =
< {
< 0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
< 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
< 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
< 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
< 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
< 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
---
> static const char XML_legacyByteTable[256] = {
> 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
482,483c644
< static const char XML_sjisByteTable[256] =
< {
---
> static const char XML_sjisByteTable[256] = {
485,500c646,661
< 0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,// 0x00
< 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,// 0x10
< 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,// 0x20
< 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,// 0x30
< 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,// 0x40
< 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,// 0x50
< 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,// 0x60
< 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,// 0x70
< 1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,// 0x80 0x81 to 0x9F 2 bytes
< 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,// 0x90
< 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,// 0xa0
< 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,// 0xb0
< 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,// 0xc0
< 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,// 0xd0
< 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,// 0xe0 0xe0 to 0xef 2 bytes
< 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 // 0xf0
---
> 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,// 0x00
> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,// 0x10
> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,// 0x20
> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,// 0x30
> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,// 0x40
> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,// 0x50
> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,// 0x60
> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,// 0x70
> 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,// 0x80 0x81 to 0x9F 2 bytes
> 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,// 0x90
> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,// 0xa0
> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,// 0xb0
> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,// 0xc0
> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,// 0xd0
> 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,// 0xe0 0xe0 to 0xef 2 bytes
> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 // 0xf0
502,503c663
< static const char XML_gb2312ByteTable[256] =
< {
---
> static const char XML_gb2312ByteTable[256] = {
505,520c665,680
< 0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,// 0x00
< 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,// 0x10
< 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,// 0x20
< 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,// 0x30
< 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,// 0x40
< 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,// 0x50
< 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,// 0x60
< 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,// 0x70
< 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,// 0x80
< 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,// 0x90
< 1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,// 0xa0 0xa1 to 0xf7 2 bytes
< 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,// 0xb0
< 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,// 0xc0
< 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,// 0xd0
< 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,// 0xe0
< 2,2,2,2,2,2,2,2,1,1,1,1,1,1,1,1 // 0xf0
---
> 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,// 0x00
> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,// 0x10
> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,// 0x20
> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,// 0x30
> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,// 0x40
> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,// 0x50
> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,// 0x60
> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,// 0x70
> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,// 0x80
> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,// 0x90
> 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,// 0xa0 0xa1 to 0xf7 2 bytes
> 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,// 0xb0
> 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,// 0xc0
> 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,// 0xd0
> 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,// 0xe0
> 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1 // 0xf0
522,523c682
< static const char XML_gbk_big5_ByteTable[256] =
< {
---
> static const char XML_gbk_big5_ByteTable[256] = {
525,540c684,699
< 0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,// 0x00
< 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,// 0x10
< 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,// 0x20
< 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,// 0x30
< 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,// 0x40
< 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,// 0x50
< 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,// 0x60
< 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,// 0x70
< 1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,// 0x80 0x81 to 0xfe 2 bytes
< 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,// 0x90
< 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,// 0xa0
< 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,// 0xb0
< 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,// 0xc0
< 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,// 0xd0
< 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,// 0xe0
< 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1 // 0xf0
---
> 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,// 0x00
> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,// 0x10
> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,// 0x20
> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,// 0x30
> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,// 0x40
> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,// 0x50
> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,// 0x60
> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,// 0x70
> 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,// 0x80 0x81 to 0xfe 2 bytes
> 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,// 0x90
> 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,// 0xa0
> 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,// 0xb0
> 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,// 0xc0
> 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,// 0xd0
> 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,// 0xe0
> 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1 // 0xf0
542c701,702
< static const char *XML_ByteTable=(const char *)XML_utf8ByteTable; // the default is "characterEncoding=XMLNode::encoding_UTF8"
---
> // the default is "characterEncoding=XMLNode::encoding_UTF8"
> static const char *XML_ByteTable = (const char *)XML_utf8ByteTable;
547,548c707,708
< XMLClear XMLNode::emptyXMLClear={ NULL, NULL, NULL};
< XMLAttribute XMLNode::emptyXMLAttribute={ NULL, NULL};
---
> XMLClear XMLNode::emptyXMLClear = { NULL, NULL, NULL};
> XMLAttribute XMLNode::emptyXMLAttribute = { NULL, NULL};
551,552c711
< typedef enum XMLTokenTypeTag
< {
---
> typedef enum XMLTokenTypeTag {
566,567c725
< typedef struct XML
< {
---
> typedef struct XML {
579,580c737
< typedef struct
< {
---
> typedef struct {
586,587c743
< typedef enum Attrib
< {
---
> typedef enum Attrib {
595,596c751
< typedef enum Status
< {
---
> typedef enum Status {
601,602c756
< XMLError XMLNode::writeToFile(XMLCSTR filename, const char *encoding, char nFormat) const
< {
---
> XMLError XMLNode::writeToFile(XMLCSTR filename, const char *encoding, char nFormat) const {
604c758
< FILE *f=xfopen(filename,_CXML("wb"));
---
> FILE *f = xfopen(filename, _CXML("wb"));
607,611c761,766
< unsigned char h[2]={ 0xFF, 0xFE };
< if (!fwrite(h,2,1,f)) return eXMLErrorCannotWriteFile;
< if ((!isDeclaration())&&((d->lpszName)||(!getChildNode().isDeclaration())))
< {
< if (!fwrite(L"<?xml version=\"1.0\" encoding=\"utf-16\"?>\n",sizeof(wchar_t)*40,1,f))
---
> unsigned char h[2] = { 0xFF, 0xFE };
> if (!fwrite(h, 2, 1, f)) return eXMLErrorCannotWriteFile;
> if ((!isDeclaration()) && ((d->lpszName) ||
> (!getChildNode().isDeclaration()))) {
> if (!fwrite(L"<?xml version=\"1.0\" encoding=\"utf-16\"?>\n",
> sizeof(wchar_t)*40, 1, f))
615,618c770,772
< if ((!isDeclaration())&&((d->lpszName)||(!getChildNode().isDeclaration())))
< {
< if (characterEncoding==char_encoding_UTF8)
< {
---
> if ((!isDeclaration()) && ((d->lpszName) ||
> (!getChildNode().isDeclaration()))) {
> if (characterEncoding == char_encoding_UTF8) {
620,622c774,778
< unsigned char h[3]={0xEF,0xBB,0xBF}; if (!fwrite(h,3,1,f)) return eXMLErrorCannotWriteFile;
< encoding="utf-8";
< } else if (characterEncoding==char_encoding_ShiftJIS) encoding="SHIFT-JIS";
---
> unsigned char h[3] = {0xEF, 0xBB, 0xBF};
> if (!fwrite(h, 3, 1, f)) return eXMLErrorCannotWriteFile;
> encoding = "utf-8";
> } else if (characterEncoding == char_encoding_ShiftJIS)
> encoding = "SHIFT-JIS";
624,630c780,787
< if (!encoding) encoding="ISO-8859-1";
< if (fprintf(f,"<?xml version=\"1.0\" encoding=\"%s\"?>\n",encoding)<0) return eXMLErrorCannotWriteFile;
< } else
< {
< if (characterEncoding==char_encoding_UTF8)
< {
< unsigned char h[3]={0xEF,0xBB,0xBF}; if (!fwrite(h,3,1,f)) return eXMLErrorCannotWriteFile;
---
> if (!encoding) encoding = "ISO-8859-1";
> if (fprintf(f, "<?xml version=\"1.0\" encoding=\"%s\"?>\n", encoding)
> < 0)
> return eXMLErrorCannotWriteFile;
> } else {
> if (characterEncoding == char_encoding_UTF8) {
> unsigned char h[3] = {0xEF, 0xBB, 0xBF};
> if (!fwrite(h, 3, 1, f)) return eXMLErrorCannotWriteFile;
635,637c792,794
< XMLSTR t=createXMLString(nFormat,&i);
< if (!fwrite(t,sizeof(XMLCHAR)*i,1,f)) return eXMLErrorCannotWriteFile;
< if (fclose(f)!=0) return eXMLErrorCannotWriteFile;
---
> XMLSTR t = createXMLString(nFormat, &i);
> if (!fwrite(t, sizeof(XMLCHAR)*i, 1, f)) return eXMLErrorCannotWriteFile;
> if (fclose(f) != 0) return eXMLErrorCannotWriteFile;
643,645c800,801
< XMLSTR stringDup(XMLCSTR lpszData, int cbData)
< {
< if (lpszData==NULL) return NULL;
---
> XMLSTR stringDup(XMLCSTR lpszData, int cbData) {
> if (lpszData == NULL) return NULL;
648,651c804,806
< if (cbData==-1) cbData=(int)xstrlen(lpszData);
< lpszNew = (XMLSTR)malloc((cbData+1) * sizeof(XMLCHAR));
< if (lpszNew)
< {
---
> if (cbData == -1) cbData = (int)xstrlen(lpszData);
> lpszNew = (XMLSTR)malloc((cbData + 1) * sizeof(XMLCHAR));
> if (lpszNew) {
658,660c813,814
< XMLSTR ToXMLStringTool::toXMLUnSafe(XMLSTR dest,XMLCSTR source)
< {
< XMLSTR dd=dest;
---
> XMLSTR ToXMLStringTool::toXMLUnSafe(XMLSTR dest, XMLCSTR source) {
> XMLSTR dd = dest;
663,668c817,825
< while ((ch=*source))
< {
< entity=XMLEntities;
< do
< {
< if (ch==entity->c) {xstrcpy(dest,entity->s); dest+=entity->l; source++; goto out_of_loop1; }
---
> while ((ch = *source)) {
> entity = XMLEntities;
> do {
> if (ch == entity->c) {
> xstrcpy(dest, entity->s);
> dest += entity->l;
> source++;
> goto out_of_loop1;
> }
670c827
< } while(entity->s);
---
> } while (entity->s);
672c829
< *(dest++)=*(source++);
---
> *(dest++) = *(source++);
674,679c831,839
< switch(XML_ByteTable[(unsigned char)ch])
< {
< case 4: *(dest++)=*(source++);
< case 3: *(dest++)=*(source++);
< case 2: *(dest++)=*(source++);
< case 1: *(dest++)=*(source++);
---
> switch (XML_ByteTable[(unsigned char)ch]) {
> case 4:
> *(dest++) = *(source++);
> case 3:
> *(dest++) = *(source++);
> case 2:
> *(dest++) = *(source++);
> case 1:
> *(dest++) = *(source++);
685c845
< *dest=0;
---
> *dest = 0;
690,692c850,851
< int ToXMLStringTool::lengthXMLString(XMLCSTR source)
< {
< int r=0;
---
> int ToXMLStringTool::lengthXMLString(XMLCSTR source) {
> int r = 0;
695,700c854,861
< while ((ch=*source))
< {
< entity=XMLEntities;
< do
< {
< if (ch==entity->c) { r+=entity->l; source++; goto out_of_loop1; }
---
> while ((ch = *source)) {
> entity = XMLEntities;
> do {
> if (ch == entity->c) {
> r += entity->l;
> source++;
> goto out_of_loop1;
> }
702c863
< } while(entity->s);
---
> } while (entity->s);
704c865,866
< r++; source++;
---
> r++;
> source++;
706c868,870
< ch=XML_ByteTable[(unsigned char)ch]; r+=ch; source+=ch;
---
> ch = XML_ByteTable[(unsigned char)ch];
> r += ch;
> source += ch;
714,720c878,879
< ToXMLStringTool::~ToXMLStringTool(){ freeBuffer(); }
< void ToXMLStringTool::freeBuffer(){ if (buf) free(buf); buf=NULL; buflen=0; }
< XMLSTR ToXMLStringTool::toXML(XMLCSTR source)
< {
< int l=lengthXMLString(source)+1;
< if (l>buflen) { buflen=l; buf=(XMLSTR)realloc(buf,l*sizeof(XMLCHAR)); }
< return toXMLUnSafe(buf,source);
---
> ToXMLStringTool::~ToXMLStringTool() {
> freeBuffer();
721a881,893
> void ToXMLStringTool::freeBuffer() {
> if (buf) free(buf);
> buf = NULL;
> buflen = 0;
> }
> XMLSTR ToXMLStringTool::toXML(XMLCSTR source) {
> int l = lengthXMLString(source) + 1;
> if (l > buflen) {
> buflen = l;
> buf = (XMLSTR)realloc(buf, l * sizeof(XMLCHAR));
> }
> return toXMLUnSafe(buf, source);
> }
724,725c896
< XMLSTR fromXMLString(XMLCSTR s, int lo, XML *pXML)
< {
---
> XMLSTR fromXMLString(XMLCSTR s, int lo, XML *pXML) {
735c906
< int ll=0,j;
---
> int ll = 0, j;
737c908
< XMLCSTR ss=s;
---
> XMLCSTR ss = s;
739,750c910,923
< while ((lo>0)&&(*s))
< {
< if (*s==_CXML('&'))
< {
< if ((lo>2)&&(s[1]==_CXML('#')))
< {
< s+=2; lo-=2;
< if ((*s==_CXML('X'))||(*s==_CXML('x'))) { s++; lo--; }
< while ((*s)&&(*s!=_CXML(';'))&&((lo--)>0)) s++;
< if (*s!=_CXML(';'))
< {
< pXML->error=eXMLErrorUnknownCharacterEntity;
---
> while ((lo > 0) && (*s)) {
> if (*s == _CXML('&')) {
> if ((lo > 2) && (s[1] == _CXML('#'))) {
> s += 2;
> lo -= 2;
> if ((*s == _CXML('X')) || (*s == _CXML('x'))) {
> s++;
> lo--;
> }
> while ((*s) && (*s != _CXML(';')) && ((lo--) > 0)) {
> s++;
> }
> if (*s != _CXML(';')) {
> pXML->error = eXMLErrorUnknownCharacterEntity;
753,759c926,936
< s++; lo--;
< } else
< {
< entity=XMLEntities;
< do
< {
< if ((lo>=entity->l)&&(xstrnicmp(s,entity->s,entity->l)==0)) { s+=entity->l; lo-=entity->l; break; }
---
> s++;
> lo--;
> } else {
> entity = XMLEntities;
> do {
> if ((lo >= entity->l) &&
> (xstrnicmp(s, entity->s, entity->l) == 0)) {
> s += entity->l;
> lo -= entity->l;
> break;
> }
761,764c938,940
< } while(entity->s);
< if (!entity->s)
< {
< pXML->error=eXMLErrorUnknownCharacterEntity;
---
> } while (entity->s);
> if (!entity->s) {
> pXML->error = eXMLErrorUnknownCharacterEntity;
768,769c944
< } else
< {
---
> } else {
771c946,947
< s++; lo--;
---
> s++;
> lo--;
773c949,952
< j=XML_ByteTable[(unsigned char)*s]; s+=j; lo-=j; ll+=j-1;
---
> j = XML_ByteTable[(unsigned char)*s];
> s += j;
> lo -= j;
> ll += j - 1;
779,789c958,965
< d=(XMLSTR)malloc((ll+1)*sizeof(XMLCHAR));
< s=d;
< while (ll-->0)
< {
< if (*ss==_CXML('&'))
< {
< if (ss[1]==_CXML('#'))
< {
< ss+=2; j=0;
< if ((*ss==_CXML('X'))||(*ss==_CXML('x')))
< {
---
> d = (XMLSTR)malloc((ll + 1) * sizeof(XMLCHAR));
> s = d;
> while (ll-- > 0) {
> if (*ss == _CXML('&')) {
> if (ss[1] == _CXML('#')) {
> ss += 2;
> j = 0;
> if ((*ss == _CXML('X')) || (*ss == _CXML('x'))) {
791,796c967,978
< while (*ss!=_CXML(';'))
< {
< if ((*ss>=_CXML('0'))&&(*ss<=_CXML('9'))) j=(j<<4)+*ss-_CXML('0');
< else if ((*ss>=_CXML('A'))&&(*ss<=_CXML('F'))) j=(j<<4)+*ss-_CXML('A')+10;
< else if ((*ss>=_CXML('a'))&&(*ss<=_CXML('f'))) j=(j<<4)+*ss-_CXML('a')+10;
< else { free((void*)s); pXML->error=eXMLErrorUnknownCharacterEntity;return NULL;}
---
> while (*ss != _CXML(';')) {
> if ((*ss >= _CXML('0')) && (*ss <= _CXML('9'))) {
> j = (j << 4) + *ss - _CXML('0');
> } else if ((*ss >= _CXML('A')) && (*ss <= _CXML('F'))) {
> j = (j << 4) + *ss - _CXML('A') + 10;
> } else if ((*ss >= _CXML('a')) && (*ss <= _CXML('f'))) {
> j = (j << 4) + *ss - _CXML('a') + 10;
> } else {
> free((void*)s);
> pXML->error = eXMLErrorUnknownCharacterEntity;
> return NULL;
> }
799,804c981,989
< } else
< {
< while (*ss!=_CXML(';'))
< {
< if ((*ss>=_CXML('0'))&&(*ss<=_CXML('9'))) j=(j*10)+*ss-_CXML('0');
< else { free((void*)s); pXML->error=eXMLErrorUnknownCharacterEntity;return NULL;}
---
> } else {
> while (*ss != _CXML(';')) {
> if ((*ss >= _CXML('0')) && (*ss <= _CXML('9'))) {
> j = (j * 10) + *ss - _CXML('0');
> } else {
> free((void*)s);
> pXML->error = eXMLErrorUnknownCharacterEntity;
> return NULL;
> }
809c994,998
< if (j>255) { free((void*)s); pXML->error=eXMLErrorCharacterCodeAbove255;return NULL;}
---
> if (j > 255) {
> free((void*)s);
> pXML->error = eXMLErrorCharacterCodeAbove255;
> return NULL;
> }
811,817c1000,1009
< (*d++)=(XMLCHAR)j; ss++;
< } else
< {
< entity=XMLEntities;
< do
< {
< if (xstrnicmp(ss,entity->s,entity->l)==0) { *(d++)=entity->c; ss+=entity->l; break; }
---
> (*d++) = (XMLCHAR)j;
> ss++;
> } else {
> entity = XMLEntities;
> do {
> if (xstrnicmp(ss, entity->s, entity->l) == 0) {
> *(d++) = entity->c;
> ss += entity->l;
> break;
> }
819c1011
< } while(entity->s);
---
> } while (entity->s);
821,822c1013
< } else
< {
---
> } else {
824c1015
< *(d++)=*(ss++);
---
> *(d++) = *(ss++);
826,831c1017,1028
< switch(XML_ByteTable[(unsigned char)*ss])
< {
< case 4: *(d++)=*(ss++); ll--;
< case 3: *(d++)=*(ss++); ll--;
< case 2: *(d++)=*(ss++); ll--;
< case 1: *(d++)=*(ss++);
---
> switch (XML_ByteTable[(unsigned char)*ss]) {
> case 4:
> *(d++) = *(ss++);
> ll--;
> case 3:
> *(d++) = *(ss++);
> ll--;
> case 2:
> *(d++) = *(ss++);
> ll--;
> case 1:
> *(d++) = *(ss++);
836c1033
< *d=0;
---
> *d = 0;
849,856c1046,1053
< 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;
---
> 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;
861,862c1058
< static inline XMLCHAR getNextChar(XML *pXML)
< {
---
> static inline XMLCHAR getNextChar(XML *pXML) {
865c1061
< if (ch!=0) pXML->nIndex++;
---
> if (ch != 0) pXML->nIndex++;
867c1063
< pXML->nIndex+=XML_ByteTable[(unsigned char)ch];
---
> pXML->nIndex += XML_ByteTable[(unsigned char)ch];
874,875c1070,1071
< static NextToken GetNextToken(XML *pXML, int *pcbToken, enum XMLTokenTypeTag *pType)
< {
---
> static NextToken GetNextToken(XML *pXML, int *pcbToken,
> enum XMLTokenTypeTag *pType) {
879,880c1075,1076
< int indexStart,nFoundMatch,nIsText=FALSE;
< result.pClr=NULL; // prevent warning
---
> int indexStart, nFoundMatch, nIsText = FALSE;
> result.pClr = NULL; // prevent warning
883c1079,1082
< do { indexStart=pXML->nIndex; ch=getNextChar(pXML); } while XML_isSPACECHAR(ch);
---
> do {
> indexStart = pXML->nIndex;
> ch = getNextChar(pXML);
> } while XML_isSPACECHAR(ch);
885,886c1084
< if (ch)
< {
---
> if (ch) {
892,899c1090,1095
< ALLXMLClearTag *ctag=XMLClearTags;
< do
< {
< if (xstrncmp(ctag->lpszOpen, result.pStr, ctag->openTagLen)==0)
< {
< result.pClr=ctag;
< pXML->nIndex+=ctag->openTagLen-1;
< *pType=eTokenClear;
---
> ALLXMLClearTag *ctag = XMLClearTags;
> do {
> if (xstrncmp(ctag->lpszOpen, result.pStr, ctag->openTagLen) == 0) {
> result.pClr = ctag;
> pXML->nIndex += ctag->openTagLen - 1;
> *pType = eTokenClear;
903c1099
< } while(ctag->lpszOpen);
---
> } while (ctag->lpszOpen);
906,908c1102,1103
< switch(ch)
< {
< // Check for quotes
---
> switch (ch) {
> // Check for quotes
919,922c1114,1121
< while((ch = getNextChar(pXML)))
< {
< if (ch==chTemp) { nFoundMatch = TRUE; break; }
< if (ch==_CXML('<')) break;
---
> while ((ch = getNextChar(pXML))) {
> if (ch == chTemp) {
> nFoundMatch = TRUE;
> break;
> }
> if (ch == _CXML('<')) {
> break;
> }
926,929c1125,1127
< if (nFoundMatch == FALSE)
< {
< pXML->nIndex=indexStart+1;
< nIsText=TRUE;
---
> if (nFoundMatch == FALSE) {
> pXML->nIndex = indexStart + 1;
> nIsText = TRUE;
938c1136
< // Equals (used with attribute values)
---
> // Equals (used with attribute values)
943c1141
< // Close tag
---
> // Close tag
948c1146
< // Check for tag start and tag end
---
> // Check for tag start and tag end
956,957c1154
< if (chTemp == _CXML('/'))
< {
---
> if (chTemp == _CXML('/')) {
964,965c1161
< else if (chTemp == _CXML('?'))
< {
---
> else if (chTemp == _CXML('?')) {
973,974c1169
< else
< {
---
> else {
979c1174
< // Check to see if we have a short hand type end tag ('/>').
---
> // Check to see if we have a short hand type end tag ('/>').
986,987c1181
< if (chTemp == _CXML('>'))
< {
---
> if (chTemp == _CXML('>')) {
997c1191
< // Other characters
---
> // Other characters
1003,1004c1197
< if (nIsText)
< {
---
> if (nIsText) {
1007,1011c1200,1203
< while((ch = getNextChar(pXML)))
< {
< if XML_isSPACECHAR(ch)
< {
< indexStart++; break;
---
> while ((ch = getNextChar(pXML))) {
> if XML_isSPACECHAR(ch) {
> indexStart++;
> break;
1013,1014c1205
< } else if (ch==_CXML('/'))
< {
---
> } else if (ch == _CXML('/')) {
1017c1208
< ch=pXML->lpXML[pXML->nIndex];
---
> ch = pXML->lpXML[pXML->nIndex];
1019c1210,1213
< if (ch==_CXML('>')) { pXML->nIndex--; break; }
---
> if (ch == _CXML('>')) {
> pXML->nIndex--;
> break;
> }
1021,1023c1215,1218
< } else if ((ch==_CXML('<'))||(ch==_CXML('>'))||(ch==_CXML('=')))
< {
< pXML->nIndex--; break;
---
> } else if ((ch == _CXML('<')) || (ch == _CXML('>')) ||
> (ch == _CXML('='))) {
> pXML->nIndex--;
> break;
1027,1029c1222,1223
< *pcbToken = pXML->nIndex-indexStart;
< } else
< {
---
> *pcbToken = pXML->nIndex - indexStart;
> } else {
1033c1227
< result.pStr=NULL;
---
> result.pStr = NULL;
1039,1043c1233,1239
< XMLCSTR XMLNode::updateName_WOSD(XMLSTR lpszName)
< {
< if (!d) { free(lpszName); return NULL; }
< if (d->lpszName&&(lpszName!=d->lpszName)) free((void*)d->lpszName);
< d->lpszName=lpszName;
---
> XMLCSTR XMLNode::updateName_WOSD(XMLSTR lpszName) {
> if (!d) {
> free(lpszName);
> return NULL;
> }
> if (d->lpszName && (lpszName != d->lpszName)) free((void*)d->lpszName);
> d->lpszName = lpszName;
1048,1052c1244,1250
< XMLNode::XMLNode(struct XMLNodeDataTag *p){ d=p; (p->ref_count)++; }
< XMLNode::XMLNode(XMLNodeData *pParent, XMLSTR lpszName, char isDeclaration)
< {
< d=(XMLNodeData*)malloc(sizeof(XMLNodeData));
< d->ref_count=1;
---
> XMLNode::XMLNode(struct XMLNodeDataTag *p) {
> d = p;
> (p->ref_count)++;
> }
> XMLNode::XMLNode(XMLNodeData *pParent, XMLSTR lpszName, char isDeclaration) {
> d = (XMLNodeData*)malloc(sizeof(XMLNodeData));
> d->ref_count = 1;
1054,1055c1252,1253
< d->lpszName=NULL;
< d->nChild= 0;
---
> d->lpszName = NULL;
> d->nChild = 0;
1063,1067c1261,1265
< d->pChild= NULL;
< d->pText= NULL;
< d->pClear= NULL;
< d->pAttribute= NULL;
< d->pOrder= NULL;
---
> d->pChild = NULL;
> d->pText = NULL;
> d->pClear = NULL;
> d->pAttribute = NULL;
> d->pOrder = NULL;
1072,1073c1270,1275
< XMLNode XMLNode::createXMLTopNode_WOSD(XMLSTR lpszName, char isDeclaration) { return XMLNode(NULL,lpszName,isDeclaration); }
< XMLNode XMLNode::createXMLTopNode(XMLCSTR lpszName, char isDeclaration) { return XMLNode(NULL,stringDup(lpszName),isDeclaration); }
---
> XMLNode XMLNode::createXMLTopNode_WOSD(XMLSTR lpszName, char isDeclaration) {
> return XMLNode(NULL, lpszName, isDeclaration);
> }
> XMLNode XMLNode::createXMLTopNode(XMLCSTR lpszName, char isDeclaration) {
> return XMLNode(NULL, stringDup(lpszName), isDeclaration);
> }
1077,1081c1279,1289
< 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);
---
> 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);
> }
1090,1093c1298,1303
< XMLElementPosition XMLNode::findPosition(XMLNodeData *d, int index, XMLElementType xxtype)
< {
< if (index<0) return -1;
< int i=0,j=(int)((index<<2)+xxtype),*o=d->pOrder; while (o[i]!=j) i++; return i;
---
> XMLElementPosition XMLNode::findPosition(XMLNodeData *d, int index,
> XMLElementType xxtype) {
> if (index < 0) return -1;
> int i = 0, j = (int)((index << 2) + xxtype), *o = d->pOrder;
> while (o[i] != j) i++;
> return i;
1098,1103c1308,1314
< int XMLNode::removeOrderElement(XMLNodeData *d, XMLElementType t, int index)
< {
< int n=d->nChild+d->nText+d->nClear, *o=d->pOrder,i=findPosition(d,index,t);
< memmove(o+i, o+i+1, (n-i)*sizeof(int));
< for (;i<n;i++)
< if ((o[i]&3)==(int)t) o[i]-=4;
---
> int XMLNode::removeOrderElement(XMLNodeData *d, XMLElementType t, int index) {
> int n = d->nChild + d->nText + d->nClear;
> int *o = d->pOrder;
> int i = findPosition(d, index, t);
> memmove(o + i, o + i + 1, (n - i)*sizeof(int));
> for (; i < n; i++)
> if ((o[i]&3) == (int)t) o[i] -= 4;
1111,1112c1322,1323
< void *XMLNode::addToOrder(int memoryIncrease,int *_pos, int nc, void *p, int size, XMLElementType xtype)
< {
---
> void *XMLNode::addToOrder(int memoryIncrease, int *_pos, int nc, void *p,
> int size, XMLElementType xtype) {
1115,1118c1326,1330
< p=myRealloc(p,(nc+1),memoryIncrease,size);
< int n=d->nChild+d->nText+d->nClear;
< d->pOrder=(int*)myRealloc(d->pOrder,n+1,memoryIncrease*3,sizeof(int));
< int pos=*_pos,*o=d->pOrder;
---
> p = myRealloc(p, (nc + 1), memoryIncrease, size);
> int n = d->nChild + d->nText + d->nClear;
> d->pOrder = (int*)myRealloc(d->pOrder, n + 1, memoryIncrease * 3,
> sizeof(int));
> int pos = *_pos, *o = d->pOrder;
1120c1332,1336
< 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;
> }
1122,1123c1338,1339
< int i=pos;
< memmove(o+i+1, o+i, (n-i)*sizeof(int));
---
> int i = pos;
> memmove(o + i + 1, o + i, (n - i)*sizeof(int));
1125,1126c1341,1346
< while ((pos<n)&&((o[pos]&3)!=(int)xtype)) pos++;
< if (pos==n) { *_pos=nc; o[n]=(int)((nc<<2)+xtype); return p; }
---
> while ((pos < n) && ((o[pos]&3) != (int)xtype)) pos++;
> if (pos == n) {
> *_pos = nc;
> o[n] = (int)((nc << 2) + xtype);
> return p;
> }
1128,1129c1348,1349
< o[i]=o[pos];
< for (i=pos+1;i<=n;i++) if ((o[i]&3)==(int)xtype) o[i]+=4;
---
> o[i] = o[pos];
> for (i = pos + 1; i <= n; i++) if ((o[i]&3) == (int)xtype) o[i] += 4;
1131,1132c1351,1352
< *_pos=pos=o[pos]>>2;
< memmove(((char*)p)+(pos+1)*size,((char*)p)+pos*size,(nc-pos)*size);
---
> *_pos = pos = o[pos] >> 2;
> memmove(((char*)p) + (pos + 1)*size, ((char*)p) + pos*size, (nc - pos)*size);
1138,1139c1358,1359
< XMLNode XMLNode::addChild_priv(int memoryIncrease, XMLSTR lpszName, char isDeclaration, int pos)
< {
---
> XMLNode XMLNode::addChild_priv(int memoryIncrease, XMLSTR lpszName,
> char isDeclaration, int pos) {
1141,1143c1361,1364
< 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);
---
> 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);
1149,1150c1370,1371
< XMLAttribute *XMLNode::addAttribute_priv(int memoryIncrease,XMLSTR lpszName, XMLSTR lpszValuev)
< {
---
> XMLAttribute *XMLNode::addAttribute_priv(int memoryIncrease, XMLSTR lpszName,
> XMLSTR lpszValuev) {
1152,1155c1373,1382
< 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;
---
> 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;
1163,1164c1390
< XMLCSTR XMLNode::addText_priv(int memoryIncrease, XMLSTR lpszValue, int pos)
< {
---
> XMLCSTR XMLNode::addText_priv(int memoryIncrease, XMLSTR lpszValue, int pos) {
1166,1168c1392,1398
< if (!d) { myFree(lpszValue); return NULL; }
< d->pText=(XMLCSTR*)addToOrder(memoryIncrease,&pos,d->nText,d->pText,sizeof(XMLSTR),eNodeText);
< d->pText[pos]=lpszValue;
---
> if (!d) {
> myFree(lpszValue);
> return NULL;
> }
> d->pText = (XMLCSTR*)addToOrder(memoryIncrease, &pos, d->nText, d->pText,
> sizeof(XMLSTR), eNodeText);
> d->pText[pos] = lpszValue;
1174,1175c1404,1406
< XMLClear *XMLNode::addClear_priv(int memoryIncrease, XMLSTR lpszValue, XMLCSTR lpszOpen, XMLCSTR lpszClose, int pos)
< {
---
> XMLClear *XMLNode::addClear_priv(int memoryIncrease, XMLSTR lpszValue,
> XMLCSTR lpszOpen, XMLCSTR lpszClose,
> int pos) {
1177,1179c1408,1415
< if (!d) { myFree(lpszValue); return &emptyXMLClear; }
< d->pClear=(XMLClear *)addToOrder(memoryIncrease,&pos,d->nClear,d->pClear,sizeof(XMLClear),eNodeClear);
< XMLClear *pNewClear=d->pClear+pos;
---
> if (!d) {
> myFree(lpszValue);
> return &emptyXMLClear;
> }
> d->pClear = (XMLClear *)addToOrder(memoryIncrease, &pos, d->nClear,
> d->pClear, sizeof(XMLClear),
> eNodeClear);
> XMLClear *pNewClear = d->pClear + pos;
1181,1182c1417,1418
< if (!lpszOpen) lpszOpen=XMLClearTags->lpszOpen;
< if (!lpszClose) lpszClose=XMLClearTags->lpszClose;
---
> if (!lpszOpen) lpszOpen = XMLClearTags->lpszOpen;
> if (!lpszClose) lpszClose = XMLClearTags->lpszClose;
1191,1198c1427,1433
< char XMLNode::parseClearTag(void *px, void *_pClear)
< {
< XML *pXML=(XML *)px;
< ALLXMLClearTag pClear=*((ALLXMLClearTag*)_pClear);
< int cbTemp=0;
< XMLCSTR lpszTemp=NULL;
< XMLCSTR lpXML=&pXML->lpXML[pXML->nIndex];
< static XMLCSTR docTypeEnd=_CXML("]>");
---
> char XMLNode::parseClearTag(void *px, void *_pClear) {
> XML *pXML = (XML *)px;
> ALLXMLClearTag pClear = *((ALLXMLClearTag*)_pClear);
> int cbTemp = 0;
> XMLCSTR lpszTemp = NULL;
> XMLCSTR lpXML = &pXML->lpXML[pXML->nIndex];
> static XMLCSTR docTypeEnd = _CXML("]>");
1202,1208c1437,1447
< if (pClear.lpszOpen==XMLClearTags[1].lpszOpen)
< {
< XMLCSTR pCh=lpXML;
< while (*pCh)
< {
< if (*pCh==_CXML('<')) { pClear.lpszClose=docTypeEnd; lpszTemp=xstrstr(lpXML,docTypeEnd); break; }
< else if (*pCh==_CXML('>')) { lpszTemp=pCh; break; }
---
> if (pClear.lpszOpen == XMLClearTags[1].lpszOpen) {
> XMLCSTR pCh = lpXML;
> while (*pCh) {
> if (*pCh == _CXML('<')) {
> pClear.lpszClose = docTypeEnd;
> lpszTemp = xstrstr(lpXML, docTypeEnd);
> break;
> } else if (*pCh == _CXML('>')) {
> lpszTemp = pCh;
> break;
> }
1212c1451
< pCh+=XML_ByteTable[(unsigned char)(*pCh)];
---
> pCh += XML_ByteTable[(unsigned char)(*pCh)];
1215c1454
< } else lpszTemp=xstrstr(lpXML, pClear.lpszClose);
---
> } else lpszTemp = xstrstr(lpXML, pClear.lpszClose);
1217,1218c1456
< if (lpszTemp)
< {
---
> if (lpszTemp) {
1222c1460
< pXML->nIndex += cbTemp+(int)xstrlen(pClear.lpszClose);
---
> pXML->nIndex += cbTemp + (int)xstrlen(pClear.lpszClose);
1225c1463,1464
< addClear_priv(MEMORYINCREASE,stringDup(lpXML,cbTemp), pClear.lpszOpen, pClear.lpszClose,-1);
---
> addClear_priv(MEMORYINCREASE, stringDup(lpXML, cbTemp),
> pClear.lpszOpen, pClear.lpszClose, -1);
1234,1240c1473,1490
< void XMLNode::exactMemory(XMLNodeData *d)
< {
< if (d->pOrder) d->pOrder=(int*)realloc(d->pOrder,(d->nChild+d->nText+d->nClear)*sizeof(int));
< if (d->pChild) d->pChild=(XMLNode*)realloc(d->pChild,d->nChild*sizeof(XMLNode));
< if (d->pAttribute) d->pAttribute=(XMLAttribute*)realloc(d->pAttribute,d->nAttribute*sizeof(XMLAttribute));
< if (d->pText) d->pText=(XMLCSTR*)realloc(d->pText,d->nText*sizeof(XMLSTR));
< if (d->pClear) d->pClear=(XMLClear *)realloc(d->pClear,d->nClear*sizeof(XMLClear));
---
> void XMLNode::exactMemory(XMLNodeData *d) {
> if (d->pOrder) {
> d->pOrder = (int*)realloc(d->pOrder, (d->nChild + d->nText + d->nClear)
> * sizeof(int));
> }
> if (d->pChild) {
> d->pChild = (XMLNode*)realloc(d->pChild, d->nChild * sizeof(XMLNode));
> }
> if (d->pAttribute) {
> d->pAttribute = (XMLAttribute*)realloc(d->pAttribute, d->nAttribute *
> sizeof(XMLAttribute));
> }
> if (d->pText) {
> d->pText = (XMLCSTR*)realloc(d->pText, d->nText * sizeof(XMLSTR));
> }
> if (d->pClear) {
> d->pClear = (XMLClear *)realloc(d->pClear, d->nClear * sizeof(XMLClear));
> }
1243,1246c1493,1495
< char XMLNode::maybeAddTxT(void *pa, XMLCSTR tokenPStr)
< {
< XML *pXML=(XML *)pa;
< XMLCSTR lpszText=pXML->lpszText;
---
> char XMLNode::maybeAddTxT(void *pa, XMLCSTR tokenPStr) {
> XML *pXML = (XML *)pa;
> XMLCSTR lpszText = pXML->lpszText;
1248c1497,1498
< if (dropWhiteSpace) while (XML_isSPACECHAR(*lpszText)&&(lpszText!=tokenPStr)) lpszText++;
---
> if (dropWhiteSpace) while (XML_isSPACECHAR(*lpszText) &&
> (lpszText != tokenPStr)) lpszText++;
1250,1253c1500,1513
< 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; }
< XMLSTR lpt=fromXMLString(lpszText,cbText,pXML);
---
> 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;
> }
> XMLSTR lpt = fromXMLString(lpszText, cbText, pXML);
1255,1257c1515,1516
< pXML->lpszText=NULL;
< if (removeCommentsInMiddleOfText && d->nText && d->nClear)
< {
---
> pXML->lpszText = NULL;
> if (removeCommentsInMiddleOfText && d->nText && d->nClear) {
1260,1265c1519,1522
< int n=d->nChild+d->nText+d->nClear-1,*o=d->pOrder;
< if (((o[n]&3)==eNodeClear)&&((o[n-1]&3)==eNodeText))
< {
< int i=o[n]>>2;
< if (d->pClear[i].lpszOpenTag==XMLClearTags[2].lpszOpen)
< {
---
> int n = d->nChild + d->nText + d->nClear - 1, *o = d->pOrder;
> if (((o[n]&3) == eNodeClear) && ((o[n-1]&3) == eNodeText)) {
> int i = o[n] >> 2;
> if (d->pClear[i].lpszOpenTag == XMLClearTags[2].lpszOpen) {
1267,1270c1524,1528
< i=o[n-1]>>2;
< n=xstrlen(d->pText[i]);
< int n2=xstrlen(lpt)+1;
< d->pText[i]=(XMLSTR)realloc((void*)d->pText[i],(n+n2)*sizeof(XMLCHAR));
---
> i = o[n-1] >> 2;
> n = xstrlen(d->pText[i]);
> int n2 = xstrlen(lpt) + 1;
> d->pText[i] = (XMLSTR)realloc((void*)d->pText[i], (n + n2) *
> sizeof(XMLCHAR));
1272c1530
< memcpy((void*)(d->pText[i]+n),lpt,n2*sizeof(XMLCHAR));
---
> memcpy((void*)(d->pText[i] + n), lpt, n2*sizeof(XMLCHAR));
1278c1536
< addText_priv(MEMORYINCREASE,lpt,-1);
---
> addText_priv(MEMORYINCREASE, lpt, -1);
1283,1285c1541,1542
< int XMLNode::ParseXMLElement(void *pa)
< {
< XML *pXML=(XML *)pa;
---
> int XMLNode::ParseXMLElement(void *pa) {
> XML *pXML = (XML *)pa;
1289,1290c1546,1547
< XMLCSTR lpszTemp=NULL;
< int cbTemp=0;
---
> XMLCSTR lpszTemp = NULL;
> int cbTemp = 0;
1299,1300c1556
< if (pXML->nFirst)
< {
---
> if (pXML->nFirst) {
1304,1305c1560
< } else
< {
---
> } else {
1311,1312c1566
< for(;;)
< {
---
> for (;;) {
1316,1317c1570
< if (xtype != eTokenError)
< {
---
> if (xtype != eTokenError) {
1319,1320c1572
< switch(status)
< {
---
> switch (status) {
1322c1574
< // If we are outside of a tag definition
---
> // If we are outside of a tag definition
1326,1328c1578,1579
< switch(xtype)
< {
< // If we have found text or quoted text
---
> switch (xtype) {
> // If we have found text or quoted text
1336c1587
< // If we found a start tag '<' and declarations '<?'
---
> // If we found a start tag '<' and declarations '<?'
1344c1595
< if (maybeAddTxT(pXML,token.pStr)) return FALSE;
---
> if (maybeAddTxT(pXML, token.pStr)) return FALSE;
1351,1352c1602
< if (xtype != eTokenText)
< {
---
> if (xtype != eTokenText) {
1362,1363c1612
< myTagCompare(d->lpszName, token.pStr) == 0)
< {
---
> myTagCompare(d->lpszName, token.pStr) == 0) {
1375c1624,1626
< pNew = addChild_priv(MEMORYINCREASE,stringDup(token.pStr,cbToken), nDeclaration,-1);
---
> pNew = addChild_priv(MEMORYINCREASE,
> stringDup(token.pStr, cbToken),
> nDeclaration, -1);
1377,1378c1628
< while (!pNew.isEmpty())
< {
---
> while (!pNew.isEmpty()) {
1384,1385c1634
< else
< {
---
> else {
1392,1393c1641
< if (pXML->cbEndTag)
< {
---
> if (pXML->cbEndTag) {
1396,1398c1644,1645
< if (!d->lpszName)
< {
< pXML->error=eXMLErrorUnmatchedEndTag;
---
> if (!d->lpszName) {
> pXML->error = eXMLErrorUnmatchedEndTag;
1406,1407c1653,1654
< if (myTagCompare(d->lpszName, pXML->lpEndTag)==0)
< {
---
> if (myTagCompare(d->lpszName,
> pXML->lpEndTag) == 0) {
1412,1416c1659,1661
< } else
< if (pXML->cbNewElement)
< {
< // If the call indicated a new element is to
< // be created on THIS element.
---
> } else if (pXML->cbNewElement) {
> // If the call indicated a new element is to
> // be created on THIS element.
1418,1421c1663,1666
< // If the name of this element matches the
< // name of the element we need to create
< // then we need to return to the caller
< // and let it process the element.
---
> // If the name of this element matches the
> // name of the element we need to create
> // then we need to return to the caller
> // and let it process the element.
1423,1430c1668,1670
< if (myTagCompare(d->lpszName, pXML->lpNewElement)==0)
< {
< return TRUE;
< }
<
< // Add the new element and recurse
< pNew = addChild_priv(MEMORYINCREASE,stringDup(pXML->lpNewElement,pXML->cbNewElement),0,-1);
< pXML->cbNewElement = 0;
---
> if (myTagCompare(d->lpszName,
> pXML->lpNewElement) == 0) {
> return TRUE;
1432,1435d1671
< else
< {
< // If we didn't have a new element to create
< pNew = emptyXMLNode;
1437c1673,1686
< }
---
> // Add the new element and recurse
> pNew =
> addChild_priv(MEMORYINCREASE,
> stringDup(pXML->
> lpNewElement,
> pXML->
> cbNewElement),
> 0, -1);
> pXML->cbNewElement = 0;
> } else {
> // If we didn't have a new element to create
> pNew = emptyXMLNode;
>
> }
1443c1692
< // If we found an end tag
---
> // If we found an end tag
1447c1696
< if (maybeAddTxT(pXML,token.pStr)) return FALSE;
---
> if (maybeAddTxT(pXML, token.pStr)) return FALSE;
1453,1454c1702
< if (xtype != eTokenText)
< {
---
> if (xtype != eTokenText) {
1462,1463c1710
< if (xtype != eTokenCloseTag)
< {
---
> if (xtype != eTokenCloseTag) {
1467c1714
< pXML->lpszText=pXML->lpXML+pXML->nIndex;
---
> pXML->lpszText = pXML->lpXML + pXML->nIndex;
1475,1476c1722,1723
< pXML->error=eXMLErrorUnmatchedEndTag;
< pXML->nIndexMissigEndTag=pXML->nIndex;
---
> pXML->error = eXMLErrorUnmatchedEndTag;
> pXML->nIndexMissigEndTag = pXML->nIndex;
1481,1482c1728,1729
< pXML->error=eXMLErrorMissingEndTag;
< pXML->nIndexMissigEndTag=pXML->nIndex;
---
> pXML->error = eXMLErrorMissingEndTag;
> pXML->nIndexMissigEndTag = pXML->nIndex;
1492c1739
< // If we found a clear (unformatted) token
---
> // If we found a clear (unformatted) token
1495c1742
< if (maybeAddTxT(pXML,token.pStr)) return FALSE;
---
> if (maybeAddTxT(pXML, token.pStr)) return FALSE;
1497c1744
< pXML->lpszText=pXML->lpXML+pXML->nIndex;
---
> pXML->lpszText = pXML->lpXML + pXML->nIndex;
1505c1752
< // If we are inside a tag definition we need to search for attributes
---
> // If we are inside a tag definition we need to search for attributes
1510,1512c1757,1758
< switch(attrib)
< {
< // If we are looking for a new attribute
---
> switch (attrib) {
> // If we are looking for a new attribute
1516,1519c1762,1764
< switch(xtype)
< {
< // If the current type is text...
< // Eg. 'attribute'
---
> switch (xtype) {
> // If the current type is text...
> // Eg. 'attribute'
1528,1529c1773,1774
< // If we found a closing tag...
< // Eg. '>'
---
> // If we found a closing tag...
> // Eg. '>'
1533c1778
< pXML->lpszText=pXML->lpXML+pXML->nIndex;
---
> pXML->lpszText = pXML->lpXML + pXML->nIndex;
1536,1537c1781,1782
< // If we found a short hand '/>' closing tag then we can
< // return to the caller
---
> // If we found a short hand '/>' closing tag then we can
> // return to the caller
1540c1785
< pXML->lpszText=pXML->lpXML+pXML->nIndex;
---
> pXML->lpszText = pXML->lpXML + pXML->nIndex;
1543c1788
< // Errors...
---
> // Errors...
1552c1797,1798
< default: break;
---
> default:
> break;
1556c1802
< // If we are looking for an equals
---
> // If we are looking for an equals
1559,1562c1805,1807
< switch(xtype)
< {
< // If the current type is text...
< // Eg. 'Attribute AnotherAttribute'
---
> switch (xtype) {
> // If the current type is text...
> // Eg. 'Attribute AnotherAttribute'
1565c1810,1811
< addAttribute_priv(MEMORYINCREASE,stringDup(lpszTemp,cbTemp), NULL);
---
> addAttribute_priv(MEMORYINCREASE,
> stringDup(lpszTemp, cbTemp), NULL);
1572,1573c1818,1819
< // If we found a closing tag 'Attribute >' or a short hand
< // closing tag 'Attribute />'
---
> // If we found a closing tag 'Attribute >' or a short hand
> // closing tag 'Attribute />'
1578c1824
< pXML->lpszText=pXML->lpXML+pXML->nIndex;
---
> pXML->lpszText = pXML->lpXML + pXML->nIndex;
1581,1582c1827
< (lpszTemp[cbTemp-1]) == _CXML('?'))
< {
---
> (lpszTemp[cbTemp-1]) == _CXML('?')) {
1584c1829,1831
< if (d->pParent && d->pParent->pParent) xtype = eTokenShortHandClose;
---
> if (d->pParent && d->pParent->pParent) {
> xtype = eTokenShortHandClose;
> }
1587,1588c1834
< if (cbTemp)
< {
---
> if (cbTemp) {
1590c1836,1837
< addAttribute_priv(MEMORYINCREASE,stringDup(lpszTemp,cbTemp), NULL);
---
> addAttribute_priv(MEMORYINCREASE,
> stringDup(lpszTemp, cbTemp), NULL);
1594,1595c1841
< if (xtype == eTokenShortHandClose)
< {
---
> if (xtype == eTokenShortHandClose) {
1604,1605c1850,1851
< // If we found the equals token...
< // Eg. 'Attribute ='
---
> // If we found the equals token...
> // Eg. 'Attribute ='
1612c1858
< // Errors...
---
> // Errors...
1620c1866,1867
< default: break;
---
> default:
> break;
1624c1871
< // If we are looking for an attribute value
---
> // If we are looking for an attribute value
1627,1631c1874,1877
< switch(xtype)
< {
< // If the current type is text or quoted text...
< // Eg. 'Attribute = "Value"' or 'Attribute = Value' or
< // 'Attribute = 'Value''.
---
> switch (xtype) {
> // If the current type is text or quoted text...
> // Eg. 'Attribute = "Value"' or 'Attribute = Value' or
> // 'Attribute = 'Value''.
1637,1638c1883
< (token.pStr[cbToken-1]) == _CXML('?'))
< {
---
> (token.pStr[cbToken-1]) == _CXML('?')) {
1642,1643c1887
< if (cbTemp)
< {
---
> if (cbTemp) {
1645,1649c1889,1895
< if (xtype==eTokenQuotedText) { token.pStr++; cbToken-=2; }
< XMLSTR attrVal=(XMLSTR)token.pStr;
< if (attrVal)
< {
< attrVal=fromXMLString(attrVal,cbToken,pXML);
---
> if (xtype == eTokenQuotedText) {
> token.pStr++;
> cbToken -= 2;
> }
> XMLSTR attrVal = (XMLSTR)token.pStr;
> if (attrVal) {
> attrVal = fromXMLString(attrVal, cbToken, pXML);
1652c1898,1900
< addAttribute_priv(MEMORYINCREASE,stringDup(lpszTemp,cbTemp),attrVal);
---
> addAttribute_priv(MEMORYINCREASE,
> stringDup(lpszTemp, cbTemp),
> attrVal);
1659c1907
< // Errors...
---
> // Errors...
1670c1918,1919
< default: break;
---
> default:
> break;
1676,1679c1925,1926
< else
< {
< if ((!d->isDeclaration)&&(d->pParent))
< {
---
> else {
> if ((!d->isDeclaration) && (d->pParent)) {
1681c1928
< pXML->error=eXMLErrorUnmatchedEndTag;
---
> pXML->error = eXMLErrorUnmatchedEndTag;
1683c1930
< pXML->error=eXMLErrorMissingEndTag;
---
> pXML->error = eXMLErrorMissingEndTag;
1685c1932
< pXML->nIndexMissigEndTag=pXML->nIndex;
---
> pXML->nIndexMissigEndTag = pXML->nIndex;
1687c1934
< maybeAddTxT(pXML,pXML->lpXML+pXML->nIndex);
---
> maybeAddTxT(pXML, pXML->lpXML + pXML->nIndex);
1694,1695c1941,1942
< static void CountLinesAndColumns(XMLCSTR lpXML, int nUpto, XMLResults *pResults)
< {
---
> static void CountLinesAndColumns(XMLCSTR lpXML, int nUpto,
> XMLResults *pResults) {
1700c1947,1948
< struct XML xml={ lpXML,lpXML, 0, 0, eXMLErrorNone, NULL, 0, NULL, 0, TRUE };
---
> struct XML xml = { lpXML, lpXML, 0, 0, eXMLErrorNone, NULL, 0, NULL, 0,
> TRUE };
1704,1705c1952
< while (xml.nIndex<nUpto)
< {
---
> while (xml.nIndex < nUpto) {
1708,1709c1955
< else
< {
---
> else {
1711c1957
< pResults->nColumn=1;
---
> pResults->nColumn = 1;
1717,1725c1963,1969
< XMLNode XMLNode::parseString(XMLCSTR lpszXML, XMLCSTR tag, XMLResults *pResults)
< {
< if (!lpszXML)
< {
< if (pResults)
< {
< pResults->error=eXMLErrorNoElements;
< pResults->nLine=0;
< pResults->nColumn=0;
---
> XMLNode XMLNode::parseString(XMLCSTR lpszXML, XMLCSTR tag,
> XMLResults *pResults) {
> if (!lpszXML) {
> if (pResults) {
> pResults->error = eXMLErrorNoElements;
> pResults->nLine = 0;
> pResults->nColumn = 0;
1730,1731c1974,1976
< XMLNode xnode(NULL,NULL,FALSE);
< struct XML xml={ lpszXML, lpszXML, 0, 0, eXMLErrorNone, NULL, 0, NULL, 0, TRUE };
---
> XMLNode xnode(NULL, NULL, FALSE);
> struct XML xml = { lpszXML, lpszXML, 0, 0, eXMLErrorNone, NULL, 0, NULL, 0,
> TRUE };
1736,1737c1981,1984
< if (!xnode.nChildNode()) error=eXMLErrorNoXMLTagFound;
< if ((xnode.nChildNode()==1)&&(xnode.nElement()==1)) xnode=xnode.getChildNode(); // skip the empty node
---
> if (!xnode.nChildNode()) error = eXMLErrorNoXMLTagFound;
> if ((xnode.nChildNode() == 1) && (xnode.nElement() == 1)) {
> xnode = xnode.getChildNode(); // skip the empty node
> }
1740,1752c1987,1996
< if ((error==eXMLErrorNone)||(error==eXMLErrorMissingEndTag)||(error==eXMLErrorNoXMLTagFound))
< {
< XMLCSTR name=xnode.getName();
< if (tag&&(*tag)&&((!name)||(xstricmp(name,tag))))
< {
< xnode=xnode.getChildNode(tag);
< if (xnode.isEmpty())
< {
< if (pResults)
< {
< pResults->error=eXMLErrorFirstTagNotFound;
< pResults->nLine=0;
< pResults->nColumn=0;
---
> if ((error == eXMLErrorNone) || (error == eXMLErrorMissingEndTag) ||
> (error == eXMLErrorNoXMLTagFound)) {
> XMLCSTR name = xnode.getName();
> if (tag && (*tag) && ((!name) || (xstricmp(name, tag)))) {
> xnode = xnode.getChildNode(tag);
> if (xnode.isEmpty()) {
> if (pResults) {
> pResults->error = eXMLErrorFirstTagNotFound;
> pResults->nLine = 0;
> pResults->nColumn = 0;
1757,1758c2001
< } else
< {
---
> } else {
1765,1766c2008
< if (pResults)
< {
---
> if (pResults) {
1770,1772c2012,2015
< if (error!=eXMLErrorNone)
< {
< if (error==eXMLErrorMissingEndTag) xml.nIndex=xml.nIndexMissigEndTag;
---
> if (error != eXMLErrorNone) {
> if (error == eXMLErrorMissingEndTag) {
> xml.nIndex = xml.nIndexMissigEndTag;
> }
1780,1790c2023,2042
< XMLNode XMLNode::parseFile(XMLCSTR filename, XMLCSTR tag, XMLResults *pResults)
< {
< if (pResults) { pResults->nLine=0; pResults->nColumn=0; }
< FILE *f=xfopen(filename,_CXML("rb"));
< if (f==NULL) { if (pResults) pResults->error=eXMLErrorFileNotFound; return emptyXMLNode; }
< fseek(f,0,SEEK_END);
< int l=ftell(f),headerSz=0;
< 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=fread(buf,1,l,f);
---
> XMLNode XMLNode::parseFile(XMLCSTR filename, XMLCSTR tag, XMLResults *pResults) {
> if (pResults) {
> pResults->nLine = 0;
> pResults->nColumn = 0;
> }
> FILE *f = xfopen(filename, _CXML("rb"));
> if (f == NULL) {
> if (pResults) pResults->error = eXMLErrorFileNotFound;
> return emptyXMLNode;
> }
> fseek(f, 0, SEEK_END);
> int l = ftell(f), headerSz = 0;
> 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 = fread(buf, 1, l, f);
1792c2044,2047
< buf[l]=0;buf[l+1]=0;buf[l+2]=0;buf[l+3]=0;
---
> buf[l] = 0;
> buf[l+1] = 0;
> buf[l+2] = 0;
> buf[l+3] = 0;
1794,1805c2049,2062
< if (guessWideCharChars)
< {
< 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);
< free(buf); buf=(unsigned char*)b2; headerSz=0;
< } else
< {
< if ((buf[0]==0xef)&&(buf[1]==0xff)) headerSz=2;
< if ((buf[0]==0xff)&&(buf[1]==0xfe)) headerSz=2;
---
> if (guessWideCharChars) {
> 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);
> free(buf);
> buf = (unsigned char*)b2;
> headerSz = 0;
> } else {
> if ((buf[0] == 0xef) && (buf[1] == 0xff)) headerSz = 2;
> if ((buf[0] == 0xff) && (buf[1] == 0xfe)) headerSz = 2;
1809,1819c2066,2077
< if (guessWideCharChars)
< {
< if (myIsTextWideChar(buf,l))
< {
< if ((buf[0]==0xef)&&(buf[1]==0xff)) headerSz=2;
< if ((buf[0]==0xff)&&(buf[1]==0xfe)) headerSz=2;
< char *b2=myWideCharToMultiByte((const wchar_t*)(buf+headerSz));
< free(buf); buf=(unsigned char*)b2; headerSz=0;
< } else
< {
< if ((buf[0]==0xef)&&(buf[1]==0xbb)&&(buf[2]==0xbf)) headerSz=3;
---
> if (guessWideCharChars) {
> if (myIsTextWideChar(buf, l)) {
> if ((buf[0] == 0xef) && (buf[1] == 0xff)) headerSz = 2;
> if ((buf[0] == 0xff) && (buf[1] == 0xfe)) headerSz = 2;
> char *b2 = myWideCharToMultiByte((const wchar_t*)(buf + headerSz));
> free(buf);
> buf = (unsigned char*)b2;
> headerSz = 0;
> } else {
> if ((buf[0] == 0xef) && (buf[1] == 0xbb) && (buf[2] == 0xbf)) {
> headerSz = 3;
> }
1824,1825c2082,2086
< if (!buf) { if (pResults) pResults->error=eXMLErrorCharConversionError; return emptyXMLNode; }
< XMLNode x=parseString((XMLSTR)(buf+headerSz),tag,pResults);
---
> if (!buf) {
> if (pResults) pResults->error = eXMLErrorCharConversionError;
> return emptyXMLNode;
> }
> XMLNode x = parseString((XMLSTR)(buf + headerSz), tag, pResults);
1830c2091,2093
< static inline void charmemset(XMLSTR dest,XMLCHAR c,int l) { while (l--) *(dest++)=c; }
---
> static inline void charmemset(XMLSTR dest, XMLCHAR c, int l) {
> while (l--) *(dest++) = c;
> }
1837,1838c2100,2101
< int XMLNode::CreateXMLStringR(XMLNodeData *pEntry, XMLSTR lpszMarker, int nFormat)
< {
---
> int XMLNode::CreateXMLStringR(XMLNodeData *pEntry, XMLSTR lpszMarker,
> int nFormat) {
1840c2103
< int cb=nFormat<0?0:nFormat;
---
> int cb = nFormat < 0 ? 0 : nFormat;
1842,1845c2105,2111
< 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;
---
> 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;
> }
1854,1855c2120
< if (cbElement)
< {
---
> if (cbElement) {
1857,1858c2122
< if (lpszMarker)
< {
---
> if (lpszMarker) {
1861,1862c2125,2126
< lpszMarker[nResult++]=_CXML('<');
< if (pEntry->isDeclaration) lpszMarker[nResult++]=_CXML('?');
---
> lpszMarker[nResult++] = _CXML('<');
> if (pEntry->isDeclaration) lpszMarker[nResult++] = _CXML('?');
1864,1865c2128,2129
< nResult+=cbElement;
< lpszMarker[nResult++]=_CXML(' ');
---
> nResult += cbElement;
> lpszMarker[nResult++] = _CXML(' ');
1867,1869c2131,2132
< } else
< {
< nResult+=cbElement+2+cb;
---
> } else {
> nResult += cbElement + 2 + cb;
1874,1876c2137,2138
< XMLAttribute *pAttr=pEntry->pAttribute;
< for (i=0; i<pEntry->nAttribute; i++)
< {
---
> XMLAttribute *pAttr = pEntry->pAttribute;
> for (i = 0; i < pEntry->nAttribute; i++) {
1879,1880c2141
< if (cb)
< {
---
> if (cb) {
1884,1892c2145,2154
< if (pAttr->lpszValue)
< {
< cb=(int)ToXMLStringTool::lengthXMLString(pAttr->lpszValue);
< if (lpszMarker)
< {
< lpszMarker[nResult]=_CXML('=');
< lpszMarker[nResult+1]=_CXML('"');
< if (cb) ToXMLStringTool::toXMLUnSafe(&lpszMarker[nResult+2],pAttr->lpszValue);
< lpszMarker[nResult+cb+2]=_CXML('"');
---
> if (pAttr->lpszValue) {
> cb = (int)ToXMLStringTool::lengthXMLString(pAttr->lpszValue);
> if (lpszMarker) {
> lpszMarker[nResult] = _CXML('=');
> lpszMarker[nResult+1] = _CXML('"');
> if (cb) {
> ToXMLStringTool::toXMLUnSafe(&lpszMarker[nResult+2],
> pAttr->lpszValue);
> }
> lpszMarker[nResult+cb+2] = _CXML('"');
1894c2156
< nResult+=cb+3;
---
> nResult += cb + 3;
1902,1907c2164,2167
< if (pEntry->isDeclaration)
< {
< if (lpszMarker)
< {
< lpszMarker[nResult-1]=_CXML('?');
< lpszMarker[nResult]=_CXML('>');
---
> if (pEntry->isDeclaration) {
> if (lpszMarker) {
> lpszMarker[nResult-1] = _CXML('?');
> lpszMarker[nResult] = _CXML('>');
1910,1912c2170,2171
< if (nFormat!=-1)
< {
< if (lpszMarker) lpszMarker[nResult]=_CXML('\n');
---
> if (nFormat != -1) {
> if (lpszMarker) lpszMarker[nResult] = _CXML('\n');
1917,1922c2176,2179
< if (nElementI)
< {
< if (lpszMarker) lpszMarker[nResult-1]=_CXML('>');
< if (nFormat>=0)
< {
< if (lpszMarker) lpszMarker[nResult]=_CXML('\n');
---
> if (nElementI) {
> if (lpszMarker) lpszMarker[nResult-1] = _CXML('>');
> if (nFormat >= 0) {
> if (lpszMarker) lpszMarker[nResult] = _CXML('\n');
1930,1933c2187,2189
< if (nFormat!=-1)
< {
< if (cbElement&&(!pEntry->isDeclaration)) nChildFormat=nFormat+1;
< else nChildFormat=nFormat;
---
> if (nFormat != -1) {
> if (cbElement && (!pEntry->isDeclaration)) nChildFormat = nFormat + 1;
> else nChildFormat = nFormat;
1937,1962c2193,2208
< for (i=0; i<nElementI; i++)
< {
< j=pEntry->pOrder[i];
< switch((XMLElementType)(j&3))
< {
< // Text nodes
< case eNodeText:
< {
< // "Text"
< XMLCSTR pChild=pEntry->pText[j>>2];
< cb = (int)ToXMLStringTool::lengthXMLString(pChild);
< if (cb)
< {
< if (nFormat>=0)
< {
< if (lpszMarker)
< {
< charmemset(&lpszMarker[nResult],INDENTCHAR,nFormat+1);
< ToXMLStringTool::toXMLUnSafe(&lpszMarker[nResult+nFormat+1],pChild);
< lpszMarker[nResult+nFormat+1+cb]=_CXML('\n');
< }
< nResult+=cb+nFormat+2;
< } else
< {
< if (lpszMarker) ToXMLStringTool::toXMLUnSafe(&lpszMarker[nResult], pChild);
< nResult += cb;
---
> for (i = 0; i < nElementI; i++) {
> j = pEntry->pOrder[i];
> switch ((XMLElementType)(j&3)) {
> // Text nodes
> case eNodeText: {
> // "Text"
> XMLCSTR pChild = pEntry->pText[j>>2];
> cb = (int)ToXMLStringTool::lengthXMLString(pChild);
> if (cb) {
> if (nFormat >= 0) {
> if (lpszMarker) {
> charmemset(&lpszMarker[nResult], INDENTCHAR,
> nFormat + 1);
> ToXMLStringTool::toXMLUnSafe(
> &lpszMarker[nResult+nFormat+1], pChild);
> lpszMarker[nResult+nFormat+1+cb] = _CXML('\n');
1963a2210,2216
> nResult += cb + nFormat + 2;
> } else {
> if (lpszMarker) {
> ToXMLStringTool::toXMLUnSafe(&lpszMarker[nResult],
> pChild);
> }
> nResult += cb;
1965d2217
< break;
1966a2219,2220
> break;
> }
1969,1983c2223,2233
< case eNodeClear:
< {
< XMLClear *pChild=pEntry->pClear+(j>>2);
< // "OpenTag"
< cb = (int)LENSTR(pChild->lpszOpenTag);
< if (cb)
< {
< if (nFormat!=-1)
< {
< if (lpszMarker)
< {
< charmemset(&lpszMarker[nResult], INDENTCHAR, nFormat+1);
< xstrcpy(&lpszMarker[nResult+nFormat+1], pChild->lpszOpenTag);
< }
< nResult+=cb+nFormat+1;
---
> case eNodeClear: {
> XMLClear *pChild = pEntry->pClear + (j >> 2);
> // "OpenTag"
> cb = (int)LENSTR(pChild->lpszOpenTag);
> if (cb) {
> if (nFormat != -1) {
> if (lpszMarker) {
> charmemset(&lpszMarker[nResult], INDENTCHAR,
> nFormat + 1);
> xstrcpy(&lpszMarker[nResult+nFormat+1],
> pChild->lpszOpenTag);
1985,1988c2235,2238
< else
< {
< if (lpszMarker)xstrcpy(&lpszMarker[nResult], pChild->lpszOpenTag);
< nResult += cb;
---
> nResult += cb + nFormat + 1;
> } else {
> if (lpszMarker) {
> xstrcpy(&lpszMarker[nResult], pChild->lpszOpenTag);
1990,1996d2239
< }
<
< // "OpenTag Value"
< cb = (int)LENSTR(pChild->lpszValue);
< if (cb)
< {
< if (lpszMarker) xstrcpy(&lpszMarker[nResult], pChild->lpszValue);
1998a2242
> }
2000,2005c2244,2248
< // "OpenTag Value CloseTag"
< cb = (int)LENSTR(pChild->lpszCloseTag);
< if (cb)
< {
< if (lpszMarker) xstrcpy(&lpszMarker[nResult], pChild->lpszCloseTag);
< nResult += cb;
---
> // "OpenTag Value"
> cb = (int)LENSTR(pChild->lpszValue);
> if (cb) {
> if (lpszMarker) {
> xstrcpy(&lpszMarker[nResult], pChild->lpszValue);
2006a2250,2251
> nResult += cb;
> }
2008,2011c2253,2257
< if (nFormat!=-1)
< {
< if (lpszMarker) lpszMarker[nResult] = _CXML('\n');
< nResult++;
---
> // "OpenTag Value CloseTag"
> cb = (int)LENSTR(pChild->lpszCloseTag);
> if (cb) {
> if (lpszMarker) {
> xstrcpy(&lpszMarker[nResult], pChild->lpszCloseTag);
2013c2259
< break;
---
> nResult += cb;
2016,2021c2262,2264
< // Element nodes
< case eNodeChild:
< {
< // Recursively add child nodes
< nResult += CreateXMLStringR(pEntry->pChild[j>>2].d, lpszMarker ? lpszMarker + nResult : 0, nChildFormat);
< break;
---
> if (nFormat != -1) {
> if (lpszMarker) lpszMarker[nResult] = _CXML('\n');
> nResult++;
2023c2266
< default: break;
---
> break;
2024a2268,2279
>
> // Element nodes
> case eNodeChild: {
> // Recursively add child nodes
> nResult += CreateXMLStringR(pEntry->pChild[j>>2].d,
> lpszMarker ? lpszMarker + nResult : 0,
> nChildFormat);
> break;
> }
> default:
> break;
> }
2027,2028c2282
< if ((cbElement)&&(!pEntry->isDeclaration))
< {
---
> if ((cbElement) && (!pEntry->isDeclaration)) {
2031,2032c2285
< if (nElementI)
< {
---
> if (nElementI) {
2034,2039c2287,2290
< if (lpszMarker)
< {
< if (nFormat >=0)
< {
< charmemset(&lpszMarker[nResult], INDENTCHAR,nFormat);
< nResult+=nFormat;
---
> if (lpszMarker) {
> if (nFormat >= 0) {
> charmemset(&lpszMarker[nResult], INDENTCHAR, nFormat);
> nResult += nFormat;
2042c2293,2294
< lpszMarker[nResult]=_CXML('<'); lpszMarker[nResult+1]=_CXML('/');
---
> lpszMarker[nResult] = _CXML('<');
> lpszMarker[nResult+1] = _CXML('/');
2047c2299
< lpszMarker[nResult]=_CXML('>');
---
> lpszMarker[nResult] = _CXML('>');
2049,2052c2301,2303
< else
< {
< lpszMarker[nResult+1]=_CXML('\n');
< nResult+=2;
---
> else {
> lpszMarker[nResult+1] = _CXML('\n');
> nResult += 2;
2054,2058c2305,2308
< } else
< {
< if (nFormat>=0) nResult+=cbElement+4+nFormat;
< else if (nFormat==-1) nResult+=cbElement+3;
< else nResult+=cbElement+4;
---
> } else {
> if (nFormat >= 0) nResult += cbElement + 4 + nFormat;
> else if (nFormat == -1) nResult += cbElement + 3;
> else nResult += cbElement + 4;
2060,2061c2310
< } else
< {
---
> } else {
2065,2068c2314,2317
< if (lpszMarker)
< {
< lpszMarker[nResult]=_CXML('/'); lpszMarker[nResult+1]=_CXML('>');
< if (nFormat != -1) lpszMarker[nResult+2]=_CXML('\n');
---
> if (lpszMarker) {
> lpszMarker[nResult] = _CXML('/');
> lpszMarker[nResult+1] = _CXML('>');
> if (nFormat != -1) lpszMarker[nResult+2] = _CXML('\n');
2088,2090c2337,2341
< XMLSTR XMLNode::createXMLString(int nFormat, int *pnSize) const
< {
< if (!d) { if (pnSize) *pnSize=0; return NULL; }
---
> XMLSTR XMLNode::createXMLString(int nFormat, int *pnSize) const {
> if (!d) {
> if (pnSize) *pnSize = 0;
> return NULL;
> }
2096c2347
< if (!dropWhiteSpace) nFormat=0;
---
> if (!dropWhiteSpace) nFormat = 0;
2101c2352
< lpszResult=(XMLSTR)malloc((cbStr+1)*sizeof(XMLCHAR));
---
> lpszResult = (XMLSTR)malloc((cbStr + 1) * sizeof(XMLCHAR));
2103c2354
< lpszResult[cbStr]=_CXML('\0');
---
> lpszResult[cbStr] = _CXML('\0');
2108,2112c2359,2362
< int XMLNode::detachFromParent(XMLNodeData *d)
< {
< XMLNode *pa=d->pParent->pChild;
< int i=0;
< while (((void*)(pa[i].d))!=((void*)d)) i++;
---
> int XMLNode::detachFromParent(XMLNodeData *d) {
> XMLNode *pa = d->pParent->pChild;
> int i = 0;
> while (((void*)(pa[i].d)) != ((void*)d)) i++;
2114,2116c2364,2370
< if (d->pParent->nChild) memmove(pa+i,pa+i+1,(d->pParent->nChild-i)*sizeof(XMLNode));
< else { free(pa); d->pParent->pChild=NULL; }
< return removeOrderElement(d->pParent,eNodeChild,i);
---
> if (d->pParent->nChild) {
> memmove(pa + i, pa + i + 1, (d->pParent->nChild - i)*sizeof(XMLNode));
> } else {
> free(pa);
> d->pParent->pChild = NULL;
> }
> return removeOrderElement(d->pParent, eNodeChild, i);
2119,2120c2373
< XMLNode::~XMLNode()
< {
---
> XMLNode::~XMLNode() {
2125,2126c2378
< void XMLNode::deleteNodeContent()
< {
---
> void XMLNode::deleteNodeContent() {
2128c2380,2384
< if (d->pParent) { detachFromParent(d); d->pParent=NULL; d->ref_count--; }
---
> if (d->pParent) {
> detachFromParent(d);
> d->pParent = NULL;
> d->ref_count--;
> }
2131,2135c2387,2389
< void XMLNode::emptyTheNode(char force)
< {
< XMLNodeData *dd=d; // warning: must stay this way!
< if ((dd->ref_count==0)||force)
< {
---
> void XMLNode::emptyTheNode(char force) {
> XMLNodeData *dd = d; // warning: must stay this way!
> if ((dd->ref_count == 0) || force) {
2139,2142c2393,2395
< for(i=0; i<dd->nChild; i++)
< {
< pc=dd->pChild+i;
< pc->d->pParent=NULL;
---
> for (i = 0; i < dd->nChild; i++) {
> pc = dd->pChild + i;
> pc->d->pParent = NULL;
2147c2400
< for(i=0; i<dd->nText; i++) free((void*)dd->pText[i]);
---
> for (i = 0; i < dd->nText; i++) free((void*)dd->pText[i]);
2149c2402
< for(i=0; i<dd->nClear; i++) free((void*)dd->pClear[i].lpszValue);
---
> for (i = 0; i < dd->nClear; i++) free((void*)dd->pClear[i].lpszValue);
2151,2152c2404
< for(i=0; i<dd->nAttribute; i++)
< {
---
> for (i = 0; i < dd->nAttribute; i++) {
2154c2406,2408
< if (dd->pAttribute[i].lpszValue) free((void*)dd->pAttribute[i].lpszValue);
---
> if (dd->pAttribute[i].lpszValue) {
> free((void*)dd->pAttribute[i].lpszValue);
> }
2159,2161c2413,2423
< dd->nChild=0; dd->nText=0; dd->nClear=0; dd->nAttribute=0;
< dd->pChild=NULL; dd->pText=NULL; dd->pClear=NULL; dd->pAttribute=NULL;
< dd->pOrder=NULL; dd->lpszName=NULL; dd->pParent=NULL;
---
> dd->nChild = 0;
> dd->nText = 0;
> dd->nClear = 0;
> dd->nAttribute = 0;
> dd->pChild = NULL;
> dd->pText = NULL;
> dd->pClear = NULL;
> dd->pAttribute = NULL;
> dd->pOrder = NULL;
> dd->lpszName = NULL;
> dd->pParent = NULL;
2163,2164c2425
< if (dd->ref_count==0)
< {
---
> if (dd->ref_count == 0) {
2166c2427
< d=NULL;
---
> d = NULL;
2170,2171c2431
< XMLNode& XMLNode::operator=( const XMLNode& A )
< {
---
> XMLNode& XMLNode::operator=( const XMLNode & A ) {
2173,2176c2433,2438
< if (this != &A)
< {
< if (d) { d->ref_count--; emptyTheNode(0); }
< d=A.d;
---
> if (this != &A) {
> if (d) {
> d->ref_count--;
> emptyTheNode(0);
> }
> d = A.d;
2182,2183c2444
< XMLNode::XMLNode(const XMLNode &A)
< {
---
> XMLNode::XMLNode(const XMLNode &A) {
2185c2446
< d=A.d;
---
> d = A.d;
2189,2190c2450
< XMLNode XMLNode::deepCopy() const
< {
---
> XMLNode XMLNode::deepCopy() const {
2192,2201c2452,2460
< XMLNode x(NULL,stringDup(d->lpszName),d->isDeclaration);
< XMLNodeData *p=x.d;
< int n=d->nAttribute;
< if (n)
< {
< p->nAttribute=n; p->pAttribute=(XMLAttribute*)malloc(n*sizeof(XMLAttribute));
< while (n--)
< {
< p->pAttribute[n].lpszName=stringDup(d->pAttribute[n].lpszName);
< p->pAttribute[n].lpszValue=stringDup(d->pAttribute[n].lpszValue);
---
> XMLNode x(NULL, stringDup(d->lpszName), d->isDeclaration);
> XMLNodeData *p = x.d;
> int n = d->nAttribute;
> if (n) {
> p->nAttribute = n;
> p->pAttribute = (XMLAttribute*)malloc(n * sizeof(XMLAttribute));
> while (n--) {
> p->pAttribute[n].lpszName = stringDup(d->pAttribute[n].lpszName);
> p->pAttribute[n].lpszValue = stringDup(d->pAttribute[n].lpszValue);
2204,2206c2463,2466
< if (d->pOrder)
< {
< n=(d->nChild+d->nText+d->nClear)*sizeof(int); p->pOrder=(int*)malloc(n); memcpy(p->pOrder,d->pOrder,n);
---
> if (d->pOrder) {
> n = (d->nChild + d->nText + d->nClear) * sizeof(int);
> p->pOrder = (int*)malloc(n);
> memcpy(p->pOrder, d->pOrder, n);
2208,2212c2468,2472
< n=d->nText;
< if (n)
< {
< p->nText=n; p->pText=(XMLCSTR*)malloc(n*sizeof(XMLCSTR));
< while(n--) p->pText[n]=stringDup(d->pText[n]);
---
> n = d->nText;
> if (n) {
> p->nText = n;
> p->pText = (XMLCSTR*)malloc(n * sizeof(XMLCSTR));
> while (n--) p->pText[n] = stringDup(d->pText[n]);
2214,2222c2474,2481
< n=d->nClear;
< if (n)
< {
< p->nClear=n; p->pClear=(XMLClear*)malloc(n*sizeof(XMLClear));
< while (n--)
< {
< p->pClear[n].lpszCloseTag=d->pClear[n].lpszCloseTag;
< p->pClear[n].lpszOpenTag=d->pClear[n].lpszOpenTag;
< p->pClear[n].lpszValue=stringDup(d->pClear[n].lpszValue);
---
> n = d->nClear;
> if (n) {
> p->nClear = n;
> p->pClear = (XMLClear*)malloc(n * sizeof(XMLClear));
> while (n--) {
> p->pClear[n].lpszCloseTag = d->pClear[n].lpszCloseTag;
> p->pClear[n].lpszOpenTag = d->pClear[n].lpszOpenTag;
> p->pClear[n].lpszValue = stringDup(d->pClear[n].lpszValue);
2225,2233c2484,2491
< n=d->nChild;
< if (n)
< {
< p->nChild=n; p->pChild=(XMLNode*)malloc(n*sizeof(XMLNode));
< while (n--)
< {
< p->pChild[n].d=NULL;
< p->pChild[n]=d->pChild[n].deepCopy();
< p->pChild[n].d->pParent=p;
---
> n = d->nChild;
> if (n) {
> p->nChild = n;
> p->pChild = (XMLNode*)malloc(n * sizeof(XMLNode));
> while (n--) {
> p->pChild[n].d = NULL;
> p->pChild[n] = d->pChild[n].deepCopy();
> p->pChild[n].d->pParent = p;
2239,2244c2497,2500
< XMLNode XMLNode::addChild(XMLNode childNode, int pos)
< {
< XMLNodeData *dc=childNode.d;
< if ((!dc)||(!d)) return childNode;
< if (!dc->lpszName)
< {
---
> XMLNode XMLNode::addChild(XMLNode childNode, int pos) {
> XMLNodeData *dc = childNode.d;
> if ((!dc) || (!d)) return childNode;
> if (!dc->lpszName) {
2246,2250c2502,2505
< int j=pos;
< while (dc->nChild)
< {
< addChild(dc->pChild[0],j);
< if (pos>=0) j++;
---
> int j = pos;
> while (dc->nChild) {
> addChild(dc->pChild[0], j);
> if (pos >= 0) j++;
2254,2255c2509,2512
< if (dc->pParent) { if ((detachFromParent(dc)<=pos)&&(dc->pParent==d)) pos--; } else dc->ref_count++;
< dc->pParent=d;
---
> if (dc->pParent) {
> if ((detachFromParent(dc) <= pos) && (dc->pParent == d)) pos--;
> } else dc->ref_count++;
> dc->pParent = d;
2258,2259c2515,2517
< d->pChild=(XMLNode*)addToOrder(0,&pos,d->nChild,d->pChild,sizeof(XMLNode),eNodeChild);
< d->pChild[pos].d=dc;
---
> d->pChild = (XMLNode*)addToOrder(0, &pos, d->nChild, d->pChild,
> sizeof(XMLNode), eNodeChild);
> d->pChild[pos].d = dc;
2264,2266c2522,2523
< void XMLNode::deleteAttribute(int i)
< {
< if ((!d)||(i<0)||(i>=d->nAttribute)) return;
---
> void XMLNode::deleteAttribute(int i) {
> if ((!d) || (i < 0) || (i >= d->nAttribute)) return;
2268c2525
< XMLAttribute *p=d->pAttribute+i;
---
> XMLAttribute *p = d->pAttribute + i;
2271c2528,2534
< if (d->nAttribute) memmove(p,p+1,(d->nAttribute-i)*sizeof(XMLAttribute)); else { free(p); d->pAttribute=NULL; }
---
> if (d->nAttribute) {
> memmove(p, p + 1, (d->nAttribute - i)*sizeof(XMLAttribute));
> }
> else {
> free(p);
> d->pAttribute = NULL;
> }
2274,2279c2537,2538
< void XMLNode::deleteAttribute(XMLAttribute *a){ if (a) deleteAttribute(a->lpszName); }
< void XMLNode::deleteAttribute(XMLCSTR lpszName)
< {
< int j=0;
< getAttribute(lpszName,&j);
< if (j) deleteAttribute(j-1);
---
> void XMLNode::deleteAttribute(XMLAttribute *a) {
> if (a) deleteAttribute(a->lpszName);
2280a2540,2544
> void XMLNode::deleteAttribute(XMLCSTR lpszName) {
> int j = 0;
> getAttribute(lpszName, &j);
> if (j) deleteAttribute(j - 1);
> }
2282,2287c2546,2550
< XMLAttribute *XMLNode::updateAttribute_WOSD(XMLSTR lpszNewValue, XMLSTR lpszNewName,int i)
< {
< if (!d) { if (lpszNewValue) free(lpszNewValue); if (lpszNewName) free(lpszNewName); return NULL; }
< if (i>=d->nAttribute)
< {
< if (lpszNewName) return addAttribute_WOSD(lpszNewName,lpszNewValue);
---
> XMLAttribute *XMLNode::updateAttribute_WOSD(XMLSTR lpszNewValue,
> XMLSTR lpszNewName, int i) {
> if (!d) {
> if (lpszNewValue) free(lpszNewValue);
> if (lpszNewName) free(lpszNewName);
2290,2293c2553,2565
< XMLAttribute *p=d->pAttribute+i;
< if (p->lpszValue&&p->lpszValue!=lpszNewValue) free((void*)p->lpszValue);
< p->lpszValue=lpszNewValue;
< if (lpszNewName&&p->lpszName!=lpszNewName) { free((void*)p->lpszName); p->lpszName=lpszNewName; };
---
> if (i >= d->nAttribute) {
> if (lpszNewName) return addAttribute_WOSD(lpszNewName, lpszNewValue);
> return NULL;
> }
> XMLAttribute *p = d->pAttribute + i;
> if (p->lpszValue && p->lpszValue != lpszNewValue) {
> free((void*)p->lpszValue);
> }
> p->lpszValue = lpszNewValue;
> if (lpszNewName && p->lpszName != lpszNewName) {
> free((void*)p->lpszName);
> p->lpszName = lpszNewName;
> };
2297,2300c2569,2577
< XMLAttribute *XMLNode::updateAttribute_WOSD(XMLAttribute *newAttribute, XMLAttribute *oldAttribute)
< {
< if (oldAttribute) return updateAttribute_WOSD((XMLSTR)newAttribute->lpszValue,(XMLSTR)newAttribute->lpszName,oldAttribute->lpszName);
< return addAttribute_WOSD((XMLSTR)newAttribute->lpszName,(XMLSTR)newAttribute->lpszValue);
---
> XMLAttribute *XMLNode::updateAttribute_WOSD(XMLAttribute *newAttribute,
> XMLAttribute *oldAttribute) {
> if (oldAttribute) {
> return updateAttribute_WOSD((XMLSTR)newAttribute->lpszValue,
> (XMLSTR)newAttribute->lpszName,
> oldAttribute->lpszName);
> }
> return addAttribute_WOSD((XMLSTR)newAttribute->lpszName,
> (XMLSTR)newAttribute->lpszValue);
2303,2311c2580,2591
< XMLAttribute *XMLNode::updateAttribute_WOSD(XMLSTR lpszNewValue, XMLSTR lpszNewName,XMLCSTR lpszOldName)
< {
< int j=0;
< getAttribute(lpszOldName,&j);
< if (j) return updateAttribute_WOSD(lpszNewValue,lpszNewName,j-1);
< else
< {
< if (lpszNewName) return addAttribute_WOSD(lpszNewName,lpszNewValue);
< else return addAttribute_WOSD(stringDup(lpszOldName),lpszNewValue);
---
> XMLAttribute *XMLNode::updateAttribute_WOSD(XMLSTR lpszNewValue,
> XMLSTR lpszNewName,
> XMLCSTR lpszOldName) {
> int j = 0;
> getAttribute(lpszOldName, &j);
> if (j) return updateAttribute_WOSD(lpszNewValue, lpszNewName, j - 1);
> else {
> if (lpszNewName) {
> return addAttribute_WOSD(lpszNewName, lpszNewValue);
> } else {
> return addAttribute_WOSD(stringDup(lpszOldName), lpszNewValue);
> }
2315,2316c2595
< int XMLNode::indexText(XMLCSTR lpszValue) const
< {
---
> int XMLNode::indexText(XMLCSTR lpszValue) const {
2318,2321c2597,2603
< int i,l=d->nText;
< if (!lpszValue) { if (l) return 0; return -1; }
< XMLCSTR *p=d->pText;
< for (i=0; i<l; i++) if (lpszValue==p[i]) return i;
---
> int i, l = d->nText;
> if (!lpszValue) {
> if (l) return 0;
> return -1;
> }
> XMLCSTR *p = d->pText;
> for (i = 0; i < l; i++) if (lpszValue == p[i]) return i;
2325,2327c2607,2608
< void XMLNode::deleteText(int i)
< {
< if ((!d)||(i<0)||(i>=d->nText)) return;
---
> void XMLNode::deleteText(int i) {
> if ((!d) || (i < 0) || (i >= d->nText)) return;
2329c2610
< XMLCSTR *p=d->pText+i;
---
> XMLCSTR *p = d->pText + i;
2331,2332c2612,2617
< if (d->nText) memmove(p,p+1,(d->nText-i)*sizeof(XMLCSTR)); else { free(p); d->pText=NULL; }
< removeOrderElement(d,eNodeText,i);
---
> if (d->nText) memmove(p, p + 1, (d->nText - i)*sizeof(XMLCSTR));
> else {
> free(p);
> d->pText = NULL;
> }
> removeOrderElement(d, eNodeText, i);
2335c2620,2622
< void XMLNode::deleteText(XMLCSTR lpszValue) { deleteText(indexText(lpszValue)); }
---
> void XMLNode::deleteText(XMLCSTR lpszValue) {
> deleteText(indexText(lpszValue));
> }
2337,2342c2624,2634
< XMLCSTR XMLNode::updateText_WOSD(XMLSTR lpszNewValue, int i)
< {
< if (!d) { if (lpszNewValue) free(lpszNewValue); return NULL; }
< if (i>=d->nText) return addText_WOSD(lpszNewValue);
< XMLCSTR *p=d->pText+i;
< if (*p!=lpszNewValue) { free((void*)*p); *p=lpszNewValue; }
---
> XMLCSTR XMLNode::updateText_WOSD(XMLSTR lpszNewValue, int i) {
> if (!d) {
> if (lpszNewValue) free(lpszNewValue);
> return NULL;
> }
> if (i >= d->nText) return addText_WOSD(lpszNewValue);
> XMLCSTR *p = d->pText + i;
> if (*p != lpszNewValue) {
> free((void*)*p);
> *p = lpszNewValue;
> }
2346,2350c2638,2644
< XMLCSTR XMLNode::updateText_WOSD(XMLSTR lpszNewValue, XMLCSTR lpszOldValue)
< {
< if (!d) { if (lpszNewValue) free(lpszNewValue); return NULL; }
< int i=indexText(lpszOldValue);
< if (i>=0) return updateText_WOSD(lpszNewValue,i);
---
> XMLCSTR XMLNode::updateText_WOSD(XMLSTR lpszNewValue, XMLCSTR lpszOldValue) {
> if (!d) {
> if (lpszNewValue) free(lpszNewValue);
> return NULL;
> }
> int i = indexText(lpszOldValue);
> if (i >= 0) return updateText_WOSD(lpszNewValue, i);
2354,2356c2648,2649
< void XMLNode::deleteClear(int i)
< {
< if ((!d)||(i<0)||(i>=d->nClear)) return;
---
> void XMLNode::deleteClear(int i) {
> if ((!d) || (i < 0) || (i >= d->nClear)) return;
2358c2651
< XMLClear *p=d->pClear+i;
---
> XMLClear *p = d->pClear + i;
2360,2361c2653,2658
< if (d->nClear) memmove(p,p+1,(d->nClear-i)*sizeof(XMLClear)); else { free(p); d->pClear=NULL; }
< removeOrderElement(d,eNodeClear,i);
---
> if (d->nClear) memmove(p, p + 1, (d->nClear - i)*sizeof(XMLClear));
> else {
> free(p);
> d->pClear = NULL;
> }
> removeOrderElement(d, eNodeClear, i);
2364,2365c2661
< int XMLNode::indexClear(XMLCSTR lpszValue) const
< {
---
> int XMLNode::indexClear(XMLCSTR lpszValue) const {
2367,2370c2663,2669
< int i,l=d->nClear;
< if (!lpszValue) { if (l) return 0; return -1; }
< XMLClear *p=d->pClear;
< for (i=0; i<l; i++) if (lpszValue==p[i].lpszValue) return i;
---
> int i, l = d->nClear;
> if (!lpszValue) {
> if (l) return 0;
> return -1;
> }
> XMLClear *p = d->pClear;
> for (i = 0; i < l; i++) if (lpszValue == p[i].lpszValue) return i;
2374,2375c2673,2678
< void XMLNode::deleteClear(XMLCSTR lpszValue) { deleteClear(indexClear(lpszValue)); }
< void XMLNode::deleteClear(XMLClear *a) { if (a) deleteClear(a->lpszValue); }
---
> void XMLNode::deleteClear(XMLCSTR lpszValue) {
> deleteClear(indexClear(lpszValue));
> }
> void XMLNode::deleteClear(XMLClear *a) {
> if (a) deleteClear(a->lpszValue);
> }
2377,2382c2680,2690
< XMLClear *XMLNode::updateClear_WOSD(XMLSTR lpszNewContent, int i)
< {
< if (!d) { if (lpszNewContent) free(lpszNewContent); return NULL; }
< if (i>=d->nClear) return addClear_WOSD(lpszNewContent);
< XMLClear *p=d->pClear+i;
< if (lpszNewContent!=p->lpszValue) { free((void*)p->lpszValue); p->lpszValue=lpszNewContent; }
---
> XMLClear *XMLNode::updateClear_WOSD(XMLSTR lpszNewContent, int i) {
> if (!d) {
> if (lpszNewContent) free(lpszNewContent);
> return NULL;
> }
> if (i >= d->nClear) return addClear_WOSD(lpszNewContent);
> XMLClear *p = d->pClear + i;
> if (lpszNewContent != p->lpszValue) {
> free((void*)p->lpszValue);
> p->lpszValue = lpszNewContent;
> }
2386,2390c2694,2701
< XMLClear *XMLNode::updateClear_WOSD(XMLSTR lpszNewContent, XMLCSTR lpszOldValue)
< {
< if (!d) { if (lpszNewContent) free(lpszNewContent); return NULL; }
< int i=indexClear(lpszOldValue);
< if (i>=0) return updateClear_WOSD(lpszNewContent,i);
---
> XMLClear *XMLNode::updateClear_WOSD(XMLSTR lpszNewContent,
> XMLCSTR lpszOldValue) {
> if (!d) {
> if (lpszNewContent) free(lpszNewContent);
> return NULL;
> }
> int i = indexClear(lpszOldValue);
> if (i >= 0) return updateClear_WOSD(lpszNewContent, i);
2394,2396c2705,2709
< XMLClear *XMLNode::updateClear_WOSD(XMLClear *newP,XMLClear *oldP)
< {
< if (oldP) return updateClear_WOSD((XMLSTR)newP->lpszValue,(XMLSTR)oldP->lpszValue);
---
> XMLClear *XMLNode::updateClear_WOSD(XMLClear *newP, XMLClear *oldP) {
> if (oldP) {
> return updateClear_WOSD((XMLSTR)newP->lpszValue,
> (XMLSTR)oldP->lpszValue);
> }
2400,2401c2713
< int XMLNode::nChildNode(XMLCSTR name) const
< {
---
> int XMLNode::nChildNode(XMLCSTR name) const {
2403,2407c2715,2718
< int i,j=0,n=d->nChild;
< XMLNode *pc=d->pChild;
< for (i=0; i<n; i++)
< {
< if (xstricmp(pc->d->lpszName, name)==0) j++;
---
> int i, j = 0, n = d->nChild;
> XMLNode *pc = d->pChild;
> for (i = 0; i < n; i++) {
> if (xstricmp(pc->d->lpszName, name) == 0) j++;
2413,2414c2724
< XMLNode XMLNode::getChildNode(XMLCSTR name, int *j) const
< {
---
> XMLNode XMLNode::getChildNode(XMLCSTR name, int *j) const {
2416,2423c2726,2731
< int i=0,n=d->nChild;
< if (j) i=*j;
< XMLNode *pc=d->pChild+i;
< for (; i<n; i++)
< {
< if (!xstricmp(pc->d->lpszName, name))
< {
< if (j) *j=i+1;
---
> int i = 0, n = d->nChild;
> if (j) i = *j;
> XMLNode *pc = d->pChild + i;
> for (; i < n; i++) {
> if (!xstricmp(pc->d->lpszName, name)) {
> if (j) *j = i + 1;
2431,2432c2739
< XMLNode XMLNode::getChildNode(XMLCSTR name, int j) const
< {
---
> XMLNode XMLNode::getChildNode(XMLCSTR name, int j) const {
2434,2438c2741,2744
< if (j>=0)
< {
< int i=0;
< while (j-->0) getChildNode(name,&i);
< return getChildNode(name,&i);
---
> if (j >= 0) {
> int i = 0;
> while (j-- > 0) getChildNode(name, &i);
> return getChildNode(name, &i);
2440,2442c2746,2748
< int i=d->nChild;
< while (i--) if (!xstricmp(name,d->pChild[i].d->lpszName)) break;
< if (i<0) return emptyXMLNode;
---
> int i = d->nChild;
> while (i--) if (!xstricmp(name, d->pChild[i].d->lpszName)) break;
> if (i < 0) return emptyXMLNode;
2446,2449c2752,2770
< XMLNode XMLNode::getChildNodeByPath(XMLCSTR _path, char createMissing, XMLCHAR sep)
< {
< XMLSTR path=stringDup(_path);
< XMLNode x=getChildNodeByPathNonConst(path,createMissing,sep);
---
> XMLNode* XMLNode::getChildNodePtr(XMLCSTR name, int *j) const {
> if (!d) return &emptyXMLNode;
> int i = 0, n = d->nChild;
> int foundIndex = 0;
> XMLNode *pc = d->pChild + i;
> for (; i < n; i++) {
> if (!xstricmp(pc->d->lpszName, name)) {
> if (*j == foundIndex) return pc;
> foundIndex++;
> }
> pc++;
> }
> return &emptyXMLNode;
> }
>
> XMLNode XMLNode::getChildNodeByPath(XMLCSTR _path, char createMissing,
> XMLCHAR sep) {
> XMLSTR path = stringDup(_path);
> XMLNode x = getChildNodeByPathNonConst(path, createMissing, sep);
2454,2467c2775,2791
< XMLNode XMLNode::getChildNodeByPathNonConst(XMLSTR path, char createIfMissing, XMLCHAR sep)
< {
< if ((!path)||(!(*path))) return *this;
< XMLNode xn,xbase=*this;
< XMLCHAR *tend1,sepString[2]; sepString[0]=sep; sepString[1]=0;
< tend1=xstrstr(path,sepString);
< while(tend1)
< {
< *tend1=0;
< xn=xbase.getChildNode(path);
< if (xn.isEmpty())
< {
< if (createIfMissing) xn=xbase.addChild(path);
< else { *tend1=sep; return XMLNode::emptyXMLNode; }
---
> XMLNode XMLNode::getChildNodeByPathNonConst(XMLSTR path,
> char createIfMissing, XMLCHAR sep) {
> if ((!path) || (!(*path))) return *this;
> XMLNode xn, xbase = *this;
> XMLCHAR *tend1, sepString[2];
> sepString[0] = sep;
> sepString[1] = 0;
> tend1 = xstrstr(path, sepString);
> while (tend1) {
> *tend1 = 0;
> xn = xbase.getChildNode(path);
> if (xn.isEmpty()) {
> if (createIfMissing) xn = xbase.addChild(path);
> else {
> *tend1 = sep;
> return XMLNode::emptyXMLNode;
> }
2469,2472c2793,2796
< *tend1=sep;
< xbase=xn;
< path=tend1+1;
< tend1=xstrstr(path,sepString);
---
> *tend1 = sep;
> xbase = xn;
> path = tend1 + 1;
> tend1 = xstrstr(path, sepString);
2474,2475c2798,2799
< xn=xbase.getChildNode(path);
< if (xn.isEmpty()&&createIfMissing) xn=xbase.addChild(path);
---
> xn = xbase.getChildNode(path);
> if (xn.isEmpty() && createIfMissing) xn = xbase.addChild(path);
2479,2491c2803,2830
< 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)); }
< XMLElementPosition XMLNode::positionOfClear(XMLCSTR lpszValue) const { return positionOfClear(indexClear(lpszValue)); }
< 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;
< XMLNodeData *dd=x.d;
< XMLNode *pc=d->pChild;
< int i=d->nChild;
< while (i--) if (pc[i].d==dd) return findPosition(d,i,eNodeChild);
---
> 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));
> }
> XMLElementPosition XMLNode::positionOfClear(XMLCSTR lpszValue) const {
> return positionOfClear(indexClear(lpszValue));
> }
> 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;
> XMLNodeData *dd = x.d;
> XMLNode *pc = d->pChild;
> int i = d->nChild;
> while (i--) if (pc[i].d == dd) return findPosition(d, i, eNodeChild);
2494,2495c2833
< XMLElementPosition XMLNode::positionOfChildNode(XMLCSTR name, int count) const
< {
---
> XMLElementPosition XMLNode::positionOfChildNode(XMLCSTR name, int count) const {
2497,2499c2835,2840
< int j=0;
< do { getChildNode(name,&j); if (j<0) return -1; } while (count--);
< return findPosition(d,j-1,eNodeChild);
---
> int j = 0;
> do {
> getChildNode(name, &j);
> if (j < 0) return -1;
> } while (count--);
> return findPosition(d, j - 1, eNodeChild);
2502,2527c2843,2870
< XMLNode XMLNode::getChildNodeWithAttribute(XMLCSTR name,XMLCSTR attributeName,XMLCSTR attributeValue, int *k) const
< {
< int i=0,j;
< if (k) i=*k;
< XMLNode x;
< XMLCSTR t;
< do
< {
< x=getChildNode(name,&i);
< if (!x.isEmpty())
< {
< if (attributeValue)
< {
< j=0;
< do
< {
< t=x.getAttribute(attributeName,&j);
< if (t&&(xstricmp(attributeValue,t)==0)) { if (k) *k=i; return x; }
< } while (t);
< } else
< {
< if (x.isAttributeSet(attributeName)) { if (k) *k=i; return x; }
< }
< }
< } while (!x.isEmpty());
< return emptyXMLNode;
---
> XMLNode XMLNode::getChildNodeWithAttribute(XMLCSTR name, XMLCSTR attributeName,
> XMLCSTR attributeValue,
> int *k) const {
> int i = 0, j;
> if (k) i = *k;
> XMLNode x;
> XMLCSTR t;
> do {
> x = getChildNode(name, &i);
> if (!x.isEmpty()) {
> if (attributeValue) {
> j = 0;
> do {
> t = x.getAttribute(attributeName, &j);
> if (t && (xstricmp(attributeValue, t) == 0)) {
> if (k) *k = i;
> return x;
> }
> } while (t);
> } else {
> if (x.isAttributeSet(attributeName)) {
> if (k) *k = i;
> return x;
> }
> }
> }
> } while (!x.isEmpty());
> return emptyXMLNode;
2531,2532c2874
< XMLCSTR XMLNode::getAttribute(XMLCSTR lpszAttrib, int *j) const
< {
---
> XMLCSTR XMLNode::getAttribute(XMLCSTR lpszAttrib, int *j) const {
2534,2541c2876,2881
< int i=0,n=d->nAttribute;
< if (j) i=*j;
< XMLAttribute *pAttr=d->pAttribute+i;
< for (; i<n; i++)
< {
< if (xstricmp(pAttr->lpszName, lpszAttrib)==0)
< {
< if (j) *j=i+1;
---
> int i = 0, n = d->nAttribute;
> if (j) i = *j;
> XMLAttribute *pAttr = d->pAttribute + i;
> for (; i < n; i++) {
> if (xstricmp(pAttr->lpszName, lpszAttrib) == 0) {
> if (j) *j = i + 1;
2549,2550c2889
< char XMLNode::isAttributeSet(XMLCSTR lpszAttrib) const
< {
---
> char XMLNode::isAttributeSet(XMLCSTR lpszAttrib) const {
2552,2557c2891,2894
< int i,n=d->nAttribute;
< XMLAttribute *pAttr=d->pAttribute;
< for (i=0; i<n; i++)
< {
< if (xstricmp(pAttr->lpszName, lpszAttrib)==0)
< {
---
> int i, n = d->nAttribute;
> XMLAttribute *pAttr = d->pAttribute;
> for (i = 0; i < n; i++) {
> if (xstricmp(pAttr->lpszName, lpszAttrib) == 0) {
2565,2566c2902
< XMLCSTR XMLNode::getAttribute(XMLCSTR name, int j) const
< {
---
> XMLCSTR XMLNode::getAttribute(XMLCSTR name, int j) const {
2568,2570c2904,2906
< int i=0;
< while (j-->0) getAttribute(name,&i);
< return getAttribute(name,&i);
---
> int i = 0;
> while (j-- > 0) getAttribute(name, &i);
> return getAttribute(name, &i);
2573,2574c2909
< XMLNodeContents XMLNode::enumContents(int i) const
< {
---
> XMLNodeContents XMLNode::enumContents(int i) const {
2576,2580c2911,2912
< if (!d) { c.etype=eNodeNULL; return c; }
< if (i<d->nAttribute)
< {
< c.etype=eNodeAttribute;
< c.attrib=d->pAttribute[i];
---
> if (!d) {
> c.etype = eNodeNULL;
2583,2591c2915,2918
< i-=d->nAttribute;
< c.etype=(XMLElementType)(d->pOrder[i]&3);
< i=(d->pOrder[i])>>2;
< switch (c.etype)
< {
< case eNodeChild: c.child = d->pChild[i]; break;
< case eNodeText: c.text = d->pText[i]; break;
< case eNodeClear: c.clear = d->pClear[i]; break;
< default: break;
---
> if (i < d->nAttribute) {
> c.etype = eNodeAttribute;
> c.attrib = d->pAttribute[i];
> return c;
2592a2920,2935
> i -= d->nAttribute;
> c.etype = (XMLElementType)(d->pOrder[i] & 3);
> i = (d->pOrder[i]) >> 2;
> switch (c.etype) {
> case eNodeChild:
> c.child = d->pChild[i];
> break;
> case eNodeText:
> c.text = d->pText[i];
> break;
> case eNodeClear:
> c.clear = d->pClear[i];
> break;
> default:
> break;
> }
2596,2611c2939,3000
< 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;
> }
2613,2646c3002,3064
< XMLNode XMLNode::addChild(XMLCSTR lpszName, char isDeclaration, XMLElementPosition pos)
< { return addChild_priv(0,stringDup(lpszName),isDeclaration,pos); }
< XMLNode XMLNode::addChild_WOSD(XMLSTR lpszName, char isDeclaration, XMLElementPosition pos)
< { return addChild_priv(0,lpszName,isDeclaration,pos); }
< XMLAttribute *XMLNode::addAttribute(XMLCSTR lpszName, XMLCSTR lpszValue)
< { return addAttribute_priv(0,stringDup(lpszName),stringDup(lpszValue)); }
< XMLAttribute *XMLNode::addAttribute_WOSD(XMLSTR lpszName, XMLSTR lpszValuev)
< { return addAttribute_priv(0,lpszName,lpszValuev); }
< XMLCSTR XMLNode::addText(XMLCSTR lpszValue, XMLElementPosition pos)
< { return addText_priv(0,stringDup(lpszValue),pos); }
< XMLCSTR XMLNode::addText_WOSD(XMLSTR lpszValue, XMLElementPosition pos)
< { return addText_priv(0,lpszValue,pos); }
< XMLClear *XMLNode::addClear(XMLCSTR lpszValue, XMLCSTR lpszOpen, XMLCSTR lpszClose, XMLElementPosition pos)
< { return addClear_priv(0,stringDup(lpszValue),lpszOpen,lpszClose,pos); }
< XMLClear *XMLNode::addClear_WOSD(XMLSTR lpszValue, XMLCSTR lpszOpen, XMLCSTR lpszClose, XMLElementPosition pos)
< { return addClear_priv(0,lpszValue,lpszOpen,lpszClose,pos); }
< XMLCSTR XMLNode::updateName(XMLCSTR lpszName)
< { return updateName_WOSD(stringDup(lpszName)); }
< XMLAttribute *XMLNode::updateAttribute(XMLAttribute *newAttribute, XMLAttribute *oldAttribute)
< { return updateAttribute_WOSD(stringDup(newAttribute->lpszValue),stringDup(newAttribute->lpszName),oldAttribute->lpszName); }
< XMLAttribute *XMLNode::updateAttribute(XMLCSTR lpszNewValue, XMLCSTR lpszNewName,int i)
< { return updateAttribute_WOSD(stringDup(lpszNewValue),stringDup(lpszNewName),i); }
< XMLAttribute *XMLNode::updateAttribute(XMLCSTR lpszNewValue, XMLCSTR lpszNewName,XMLCSTR lpszOldName)
< { return updateAttribute_WOSD(stringDup(lpszNewValue),stringDup(lpszNewName),lpszOldName); }
< XMLCSTR XMLNode::updateText(XMLCSTR lpszNewValue, int i)
< { return updateText_WOSD(stringDup(lpszNewValue),i); }
< XMLCSTR XMLNode::updateText(XMLCSTR lpszNewValue, XMLCSTR lpszOldValue)
< { return updateText_WOSD(stringDup(lpszNewValue),lpszOldValue); }
< XMLClear *XMLNode::updateClear(XMLCSTR lpszNewContent, int i)
< { return updateClear_WOSD(stringDup(lpszNewContent),i); }
< XMLClear *XMLNode::updateClear(XMLCSTR lpszNewValue, XMLCSTR lpszOldValue)
< { return updateClear_WOSD(stringDup(lpszNewValue),lpszOldValue); }
< XMLClear *XMLNode::updateClear(XMLClear *newP,XMLClear *oldP)
< { return updateClear_WOSD(stringDup(newP->lpszValue),oldP->lpszValue); }
---
> XMLNode XMLNode::addChild(XMLCSTR lpszName, char isDeclaration,
> XMLElementPosition pos) {
> return addChild_priv(0, stringDup(lpszName), isDeclaration, pos);
> }
> XMLNode XMLNode::addChild_WOSD(XMLSTR lpszName, char isDeclaration,
> XMLElementPosition pos) {
> return addChild_priv(0, lpszName, isDeclaration, pos);
> }
> XMLAttribute *XMLNode::addAttribute(XMLCSTR lpszName, XMLCSTR lpszValue) {
> return addAttribute_priv(0, stringDup(lpszName), stringDup(lpszValue));
> }
> XMLAttribute *XMLNode::addAttribute_WOSD(XMLSTR lpszName, XMLSTR lpszValuev) {
> return addAttribute_priv(0, lpszName, lpszValuev);
> }
> XMLCSTR XMLNode::addText(XMLCSTR lpszValue, XMLElementPosition pos) {
> return addText_priv(0, stringDup(lpszValue), pos);
> }
> XMLCSTR XMLNode::addText_WOSD(XMLSTR lpszValue, XMLElementPosition pos) {
> return addText_priv(0, lpszValue, pos);
> }
> XMLClear *XMLNode::addClear(XMLCSTR lpszValue, XMLCSTR lpszOpen,
> XMLCSTR lpszClose, XMLElementPosition pos) {
> return addClear_priv(0, stringDup(lpszValue), lpszOpen, lpszClose, pos);
> }
> XMLClear *XMLNode::addClear_WOSD(XMLSTR lpszValue, XMLCSTR lpszOpen,
> XMLCSTR lpszClose, XMLElementPosition pos) {
> return addClear_priv(0, lpszValue, lpszOpen, lpszClose, pos);
> }
> XMLCSTR XMLNode::updateName(XMLCSTR lpszName) {
> return updateName_WOSD(stringDup(lpszName));
> }
> XMLAttribute *XMLNode::updateAttribute(XMLAttribute *newAttribute,
> XMLAttribute *oldAttribute) {
> return updateAttribute_WOSD(stringDup(newAttribute->lpszValue),
> stringDup(newAttribute->lpszName),
> oldAttribute->lpszName);
> }
> XMLAttribute *XMLNode::updateAttribute(XMLCSTR lpszNewValue,
> XMLCSTR lpszNewName, int i) {
> return updateAttribute_WOSD(stringDup(lpszNewValue),
> stringDup(lpszNewName), i);
> }
> XMLAttribute *XMLNode::updateAttribute(XMLCSTR lpszNewValue,
> XMLCSTR lpszNewName,
> XMLCSTR lpszOldName) {
> return updateAttribute_WOSD(stringDup(lpszNewValue),
> stringDup(lpszNewName), lpszOldName);
> }
> XMLCSTR XMLNode::updateText(XMLCSTR lpszNewValue, int i) {
> return updateText_WOSD(stringDup(lpszNewValue), i);
> }
> XMLCSTR XMLNode::updateText(XMLCSTR lpszNewValue, XMLCSTR lpszOldValue) {
> return updateText_WOSD(stringDup(lpszNewValue), lpszOldValue);
> }
> XMLClear *XMLNode::updateClear(XMLCSTR lpszNewContent, int i) {
> return updateClear_WOSD(stringDup(lpszNewContent), i);
> }
> XMLClear *XMLNode::updateClear(XMLCSTR lpszNewValue, XMLCSTR lpszOldValue) {
> return updateClear_WOSD(stringDup(lpszNewValue), lpszOldValue);
> }
> XMLClear *XMLNode::updateClear(XMLClear *newP, XMLClear *oldP) {
> return updateClear_WOSD(stringDup(newP->lpszValue), oldP->lpszValue);
> }
2648,2651c3066,3072
< char XMLNode::setGlobalOptions(XMLCharEncoding _characterEncoding, char _guessWideCharChars,
< char _dropWhiteSpace, char _removeCommentsInMiddleOfText)
< {
< guessWideCharChars=_guessWideCharChars; dropWhiteSpace=_dropWhiteSpace; removeCommentsInMiddleOfText=_removeCommentsInMiddleOfText;
---
> char XMLNode::setGlobalOptions(XMLCharEncoding _characterEncoding,
> char _guessWideCharChars,
> char _dropWhiteSpace,
> char _removeCommentsInMiddleOfText) {
> guessWideCharChars = _guessWideCharChars;
> dropWhiteSpace = _dropWhiteSpace;
> removeCommentsInMiddleOfText = _removeCommentsInMiddleOfText;
2653c3074
< if (_characterEncoding) characterEncoding=_characterEncoding;
---
> if (_characterEncoding) characterEncoding = _characterEncoding;
2655,2660c3076,3092
< switch(_characterEncoding)
< {
< case char_encoding_UTF8: characterEncoding=_characterEncoding; XML_ByteTable=XML_utf8ByteTable; break;
< case char_encoding_legacy: characterEncoding=_characterEncoding; XML_ByteTable=XML_legacyByteTable; break;
< case char_encoding_ShiftJIS: characterEncoding=_characterEncoding; XML_ByteTable=XML_sjisByteTable; break;
< case char_encoding_GB2312: characterEncoding=_characterEncoding; XML_ByteTable=XML_gb2312ByteTable; break;
---
> switch (_characterEncoding) {
> case char_encoding_UTF8:
> characterEncoding = _characterEncoding;
> XML_ByteTable = XML_utf8ByteTable;
> break;
> case char_encoding_legacy:
> characterEncoding = _characterEncoding;
> XML_ByteTable = XML_legacyByteTable;
> break;
> case char_encoding_ShiftJIS:
> characterEncoding = _characterEncoding;
> XML_ByteTable = XML_sjisByteTable;
> break;
> case char_encoding_GB2312:
> characterEncoding = _characterEncoding;
> XML_ByteTable = XML_gb2312ByteTable;
> break;
2662,2663c3094,3099
< case char_encoding_GBK: characterEncoding=_characterEncoding; XML_ByteTable=XML_gbk_big5_ByteTable; break;
< default: return 1;
---
> case char_encoding_GBK:
> characterEncoding = _characterEncoding;
> XML_ByteTable = XML_gbk_big5_ByteTable;
> break;
> default:
> return 1;
2669,2670c3105,3106
< XMLNode::XMLCharEncoding XMLNode::guessCharEncoding(void *buf,int l, char useXMLEncodingAttribute)
< {
---
> XMLNode::XMLCharEncoding XMLNode::guessCharEncoding(void *buf, int l,
> char useXMLEncodingAttribute) {
2674,2677c3110,3117
< if (l<25) return (XMLCharEncoding)0;
< if (guessWideCharChars&&(myIsTextWideChar(buf,l))) return (XMLCharEncoding)0;
< unsigned char *b=(unsigned char*)buf;
< if ((b[0]==0xef)&&(b[1]==0xbb)&&(b[2]==0xbf)) return char_encoding_UTF8;
---
> if (l < 25) return (XMLCharEncoding)0;
> if (guessWideCharChars && (myIsTextWideChar(buf, l))) {
> return (XMLCharEncoding)0;
> }
> unsigned char *b = (unsigned char*)buf;
> if ((b[0] == 0xef) && (b[1] == 0xbb) && (b[2] == 0xbf)) {
> return char_encoding_UTF8;
> }
2680,2689c3120,3146
< XMLCharEncoding bestGuess=char_encoding_UTF8;
< int i=0;
< while (i<l)
< switch (XML_utf8ByteTable[b[i]])
< {
< case 4: i++; if ((i<l)&&(b[i]& 0xC0)!=0x80) { bestGuess=char_encoding_legacy; i=l; } // 10bbbbbb ?
< case 3: i++; if ((i<l)&&(b[i]& 0xC0)!=0x80) { bestGuess=char_encoding_legacy; i=l; } // 10bbbbbb ?
< case 2: i++; if ((i<l)&&(b[i]& 0xC0)!=0x80) { bestGuess=char_encoding_legacy; i=l; } // 10bbbbbb ?
< case 1: i++; break;
< case 0: i=l;
---
> XMLCharEncoding bestGuess = char_encoding_UTF8;
> int i = 0;
> while (i < l)
> switch (XML_utf8ByteTable[b[i]]) {
> case 4:
> i++;
> if ((i < l) && (b[i]& 0xC0) != 0x80) {
> bestGuess = char_encoding_legacy; // 10bbbbbb ?
> i = l;
> }
> case 3:
> i++;
> if ((i < l) && (b[i]& 0xC0) != 0x80) {
> bestGuess = char_encoding_legacy; // 10bbbbbb ?
> i = l;
> }
> case 2:
> i++;
> if ((i < l) && (b[i]& 0xC0) != 0x80) {
> bestGuess = char_encoding_legacy; // 10bbbbbb ?
> i = l;
> }
> case 1:
> i++;
> break;
> case 0:
> i = l;
2695,2698c3152,3155
< l=mmin(l,200);
< 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");
---
> l = mmin(l, 200);
> 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");
2700,2702c3157,3164
< 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++;
---
> 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++;
2704,2707c3166,3168
< if ((xstrnicmp((char*)b,"utf-8",5)==0)||
< (xstrnicmp((char*)b,"utf8",4)==0))
< {
< if (bestGuess==char_encoding_legacy) return char_encoding_error;
---
> if ((xstrnicmp((char*)b, "utf-8", 5) == 0) ||
> (xstrnicmp((char*)b, "utf8", 4) == 0)) {
> if (bestGuess == char_encoding_legacy) return char_encoding_error;
2711,2713c3172,3174
< 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, "shiftjis", 8) == 0) ||
> (xstrnicmp((char*)b, "shift-jis", 9) == 0) ||
> (xstrnicmp((char*)b, "sjis", 4) == 0)) return char_encoding_ShiftJIS;
2715,2717c3176,3178
< if (xstrnicmp((char*)b,"GB2312",6)==0) return char_encoding_GB2312;
< if (xstrnicmp((char*)b,"Big5",4)==0) return char_encoding_Big5;
< if (xstrnicmp((char*)b,"GBK",3)==0) return char_encoding_GBK;
---
> if (xstrnicmp((char*)b, "GB2312", 6) == 0) return char_encoding_GB2312;
> if (xstrnicmp((char*)b, "Big5", 4) == 0) return char_encoding_Big5;
> if (xstrnicmp((char*)b, "GBK", 3) == 0) return char_encoding_GBK;
2728c3189,3190
< static const char base64Fillchar = _CXML('='); // used to mark partial words at the end
---
> // used to mark partial words at the end
> static const char base64Fillchar = _CXML('=');
2731c3193
< XMLCSTR base64EncodeTable=_CXML("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/");
---
> XMLCSTR base64EncodeTable = _CXML("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/");
2736,2744c3198,3206
< 99,98,98,98,98,98,98,98,98,97, 97,98,98,97,98,98,98,98,98,98, 98,98,98,98,98,98,98,98,98,98, //00 -29
< 98,98,97,98,98,98,98,98,98,98, 98,98,98,62,98,98,98,63,52,53, 54,55,56,57,58,59,60,61,98,98, //30 -59
< 98,96,98,98,98, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14, 15,16,17,18,19,20,21,22,23,24, //60 -89
< 25,98,98,98,98,98,98,26,27,28, 29,30,31,32,33,34,35,36,37,38, 39,40,41,42,43,44,45,46,47,48, //90 -119
< 49,50,51,98,98,98,98,98,98,98, 98,98,98,98,98,98,98,98,98,98, 98,98,98,98,98,98,98,98,98,98, //120 -149
< 98,98,98,98,98,98,98,98,98,98, 98,98,98,98,98,98,98,98,98,98, 98,98,98,98,98,98,98,98,98,98, //150 -179
< 98,98,98,98,98,98,98,98,98,98, 98,98,98,98,98,98,98,98,98,98, 98,98,98,98,98,98,98,98,98,98, //180 -209
< 98,98,98,98,98,98,98,98,98,98, 98,98,98,98,98,98,98,98,98,98, 98,98,98,98,98,98,98,98,98,98, //210 -239
< 98,98,98,98,98,98,98,98,98,98, 98,98,98,98,98,98 //240 -255
---
> 99, 98, 98, 98, 98, 98, 98, 98, 98, 97, 97, 98, 98, 97, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, //00 -29
> 98, 98, 97, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 62, 98, 98, 98, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 98, 98, //30 -59
> 98, 96, 98, 98, 98, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, //60 -89
> 25, 98, 98, 98, 98, 98, 98, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, //90 -119
> 49, 50, 51, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, //120 -149
> 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, //150 -179
> 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, //180 -209
> 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, //210 -239
> 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98 //240 -255
2747c3209,3211
< XMLParserBase64Tool::~XMLParserBase64Tool(){ freeBuffer(); }
---
> XMLParserBase64Tool::~XMLParserBase64Tool() {
> freeBuffer();
> }
2749c3213,3217
< void XMLParserBase64Tool::freeBuffer(){ if (buf) free(buf); buf=NULL; buflen=0; }
---
> void XMLParserBase64Tool::freeBuffer() {
> if (buf) free(buf);
> buf = NULL;
> buflen = 0;
> }
2751,2754c3219,3221
< int XMLParserBase64Tool::encodeLength(int inlen, char formatted)
< {
< unsigned int i=((inlen-1)/3*4+4+1);
< if (formatted) i+=inlen/54;
---
> int XMLParserBase64Tool::encodeLength(int inlen, char formatted) {
> unsigned int i = ((inlen - 1) / 3 * 4 + 4 + 1);
> if (formatted) i += inlen / 54;
2758,2760c3225,3227
< XMLSTR XMLParserBase64Tool::encode(unsigned char *inbuf, unsigned int inlen, char formatted)
< {
< int i=encodeLength(inlen,formatted),k=17,eLen=inlen/3,j;
---
> XMLSTR XMLParserBase64Tool::encode(unsigned char *inbuf, unsigned int inlen,
> char formatted) {
> int i = encodeLength(inlen, formatted), k = 17, eLen = inlen / 3, j;
2762,2764c3229,3230
< XMLSTR curr=(XMLSTR)buf;
< for(i=0;i<eLen;i++)
< {
---
> XMLSTR curr = (XMLSTR)buf;
> for (i = 0; i < eLen; i++) {
2766c3232,3233
< j=(inbuf[0]<<16)|(inbuf[1]<<8)|inbuf[2]; inbuf+=3;
---
> j = (inbuf[0] << 16) | (inbuf[1] << 8) | inbuf[2];
> inbuf += 3;
2768,2772c3235,3245
< *(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>>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--;
> }
2774,2787c3247,3258
< eLen=inlen-eLen*3; // 0 - 2.
< if (eLen==1)
< {
< *(curr++)=base64EncodeTable[ inbuf[0]>>2 ];
< *(curr++)=base64EncodeTable[(inbuf[0]<<4)&0x3F];
< *(curr++)=base64Fillchar;
< *(curr++)=base64Fillchar;
< } else if (eLen==2)
< {
< j=(inbuf[0]<<8)|inbuf[1];
< *(curr++)=base64EncodeTable[ j>>10 ];
< *(curr++)=base64EncodeTable[(j>> 4)&0x3f];
< *(curr++)=base64EncodeTable[(j<< 2)&0x3f];
< *(curr++)=base64Fillchar;
---
> eLen = inlen - eLen * 3; // 0 - 2.
> if (eLen == 1) {
> *(curr++) = base64EncodeTable[ inbuf[0] >> 2 ];
> *(curr++) = base64EncodeTable[(inbuf[0] << 4) & 0x3F];
> *(curr++) = base64Fillchar;
> *(curr++) = base64Fillchar;
> } else if (eLen == 2) {
> j = (inbuf[0] << 8) | inbuf[1];
> *(curr++) = base64EncodeTable[ j>>10 ];
> *(curr++) = base64EncodeTable[(j>> 4)&0x3f];
> *(curr++) = base64EncodeTable[(j<< 2)&0x3f];
> *(curr++) = base64Fillchar;
2789c3260
< *(curr++)=0;
---
> *(curr++) = 0;
2793,2796c3264,3266
< unsigned int XMLParserBase64Tool::decodeSize(XMLCSTR data,XMLError *xe)
< {
< if (xe) *xe=eXMLErrorNone;
< int size=0;
---
> unsigned int XMLParserBase64Tool::decodeSize(XMLCSTR data, XMLError *xe) {
> if (xe) *xe = eXMLErrorNone;
> int size = 0;
2799,2800c3269
< while (*data)
< {
---
> while (*data) {
2802c3271,3274
< if (*data>255) { if (xe) *xe=eXMLErrorBase64DecodeIllegalCharacter; return 0; }
---
> if (*data > 255) {
> if (xe) *xe = eXMLErrorBase64DecodeIllegalCharacter;
> return 0;
> }
2804,2806c3276,3281
< c=base64DecodeTable[(unsigned char)(*data)];
< if (c<97) size++;
< else if (c==98) { if (xe) *xe=eXMLErrorBase64DecodeIllegalCharacter; return 0; }
---
> c = base64DecodeTable[(unsigned char)(*data)];
> if (c < 97) size++;
> else if (c == 98) {
> if (xe) *xe = eXMLErrorBase64DecodeIllegalCharacter;
> return 0;
> }
2809,2812c3284,3291
< if (xe&&(size%4!=0)) *xe=eXMLErrorBase64DataSizeIsNotMultipleOf4;
< if (size==0) return 0;
< do { data--; size--; } while(*data==base64Fillchar); size++;
< return (unsigned int)((size*3)/4);
---
> if (xe && (size % 4 != 0)) *xe = eXMLErrorBase64DataSizeIsNotMultipleOf4;
> if (size == 0) return 0;
> do {
> data--;
> size--;
> } while (*data == base64Fillchar);
> size++;
> return (unsigned int)((size*3) / 4);
2815,2821c3294,3299
< unsigned char XMLParserBase64Tool::decode(XMLCSTR data, unsigned char *buf, int len, XMLError *xe)
< {
< if (xe) *xe=eXMLErrorNone;
< int i=0,p=0;
< unsigned char d,c;
< for(;;)
< {
---
> unsigned char XMLParserBase64Tool::decode(XMLCSTR data, unsigned char *buf,
> int len, XMLError *xe) {
> if (xe) *xe = eXMLErrorNone;
> int i = 0, p = 0;
> unsigned char d, c;
> for (;;) {
2837,2841c3315,3320
< if (c==99) { return 2; }
< if (c==96)
< {
< if (p==(int)len) return 2;
< if (xe) *xe=eXMLErrorBase64DecodeTruncatedData;
---
> if (c == 99) {
> return 2;
> }
> if (c == 96) {
> if (p == (int)len) return 2;
> if (xe) *xe = eXMLErrorBase64DecodeTruncatedData;
2846,2848c3325,3333
< 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));
---
> 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));
2851,2855c3336,3342
< if (c==99) { if (xe) *xe=eXMLErrorBase64DecodeTruncatedData; return 1; }
< if (p==(int)len)
< {
< if (c==96) return 2;
< if (xe) *xe=eXMLErrorBase64DecodeBufferTooSmall;
---
> if (c == 99) {
> if (xe) *xe = eXMLErrorBase64DecodeTruncatedData;
> return 1;
> }
> if (p == (int)len) {
> if (c == 96) return 2;
> if (xe) *xe = eXMLErrorBase64DecodeBufferTooSmall;
2858,2859c3345,3349
< if (c==96) { if (xe) *xe=eXMLErrorBase64DecodeTruncatedData; return 1; }
< buf[p++]=(unsigned char)(((d<<4)&0xf0)|((c>>2)&0xf));
---
> if (c == 96) {
> if (xe) *xe = eXMLErrorBase64DecodeTruncatedData;
> return 1;
> }
> buf[p++] = (unsigned char)(((d << 4) & 0xf0) | ((c >> 2) & 0xf));
2862,2866c3352,3358
< if (d==99 ) { if (xe) *xe=eXMLErrorBase64DecodeTruncatedData; return 1; }
< if (p==(int)len)
< {
< if (d==96) return 2;
< if (xe) *xe=eXMLErrorBase64DecodeBufferTooSmall;
---
> if (d == 99 ) {
> if (xe) *xe = eXMLErrorBase64DecodeTruncatedData;
> return 1;
> }
> if (p == (int)len) {
> if (d == 96) return 2;
> if (xe) *xe = eXMLErrorBase64DecodeBufferTooSmall;
2869,2870c3361,3365
< if (d==96) { if (xe) *xe=eXMLErrorBase64DecodeTruncatedData; return 1; }
< buf[p++]=(unsigned char)(((c<<6)&0xc0)|d);
---
> if (d == 96) {
> if (xe) *xe = eXMLErrorBase64DecodeTruncatedData;
> return 1;
> }
> buf[p++] = (unsigned char)(((c << 6) & 0xc0) | d);
2875,2878c3370,3379
< void XMLParserBase64Tool::alloc(int newsize)
< {
< if ((!buf)&&(newsize)) { buf=malloc(newsize); buflen=newsize; return; }
< if (newsize>buflen) { buf=realloc(buf,newsize); buflen=newsize; }
---
> void XMLParserBase64Tool::alloc(int newsize) {
> if ((!buf) && (newsize)) {
> buf = malloc(newsize);
> buflen = newsize;
> return;
> }
> if (newsize > buflen) {
> buf = realloc(buf, newsize);
> buflen = newsize;
> }
2881,2885c3382,3385
< unsigned char *XMLParserBase64Tool::decode(XMLCSTR data, int *outlen, XMLError *xe)
< {
< if (xe) *xe=eXMLErrorNone;
< unsigned int len=decodeSize(data,xe);
< if (outlen) *outlen=len;
---
> unsigned char *XMLParserBase64Tool::decode(XMLCSTR data, int *outlen, XMLError *xe) {
> if (xe) *xe = eXMLErrorNone;
> unsigned int len = decodeSize(data, xe);
> if (outlen) *outlen = len;
2887,2888c3387,3390
< alloc(len+1);
< if(!decode(data,(unsigned char*)buf,len,xe)){ return NULL; }
---
> alloc(len + 1);
> if (!decode(data, (unsigned char*)buf, len, xe)) {
> return NULL;
> }