10 #ifndef _CRT_SECURE_NO_DEPRECATE    11 #define _CRT_SECURE_NO_DEPRECATE    13 #undef _UNICODE                 // JLBC    16 #define WIN32_LEAN_AND_MEAN    33 inline int mmin( 
const int t1, 
const int t2 ) { 
return t1 < t2 ? t1 : t2; }
    69 #define INDENTCHAR _CXML('\t')   100     return _CXML(
"Unknown");
   112 #ifdef XML_NO_WIDE_CHAR   115     #if defined (UNDER_CE) || !defined(_XMLWINDOWS)   120         if ((((
unsigned long)
b)%
sizeof(
wchar_t))!=0) 
return FALSE;
   122         const wchar_t *
s=(
const wchar_t*)
b;
   125         if (
len<(
int)
sizeof(wchar_t)) 
return FALSE;
   134         if (*((
unsigned short*)
s) == 0xFFFE) 
return TRUE;     
   135         if (*((
unsigned short*)
s) == 0xFEFF) 
return TRUE;      
   139         for (i=0; i<
len; i++) 
if (
s[i]<=(
unsigned short)255) stats++;
   143         for (i=0; i<
len; i++) 
if (!
s[i]) 
return TRUE;
   159             else                            i=(int)MultiByteToWideChar(CP_ACP ,MB_PRECOMPOSED,
s,-1,NULL,0);
   160             if (i<0) 
return NULL;
   161             wchar_t *d=(
wchar_t *)malloc((i+1)*
sizeof(
XMLCHAR));
   163             else                            i=(int)MultiByteToWideChar(CP_ACP ,MB_PRECOMPOSED,
s,-1,d,i);
   178             int i=(int)WideCharToMultiByte(codePage,  
   187             if (i<0) 
return NULL;
   188             char *d=(
char*)malloc(i+1);
   189             WideCharToMultiByte(codePage,  
   216     #ifdef XML_NO_WIDE_CHAR   222             int i=(int)wcsrtombs(NULL,&ss,0,NULL);
   223             if (i<0) 
return NULL;
   224             char *d=(
char *)malloc(i+1);
   225             wcsrtombs(d,&
s,i,NULL);
   234             int i=(int)mbsrtowcs(NULL,&ss,0,NULL);
   235             if (i<0) 
return NULL;
   236             wchar_t *d=(
wchar_t *)malloc((i+1)*
sizeof(wchar_t));
   237             mbsrtowcs(d,&
s,i,NULL);
   261             else                     f=
fopen(filenameAscii,
"wb");
   275 #pragma clang diagnostic push   276 #pragma clang diagnostic ignored "-Wunused-function"   277     static inline int _strnicmp(
const char *c1,
const char *c2, 
int l) { 
return strncasecmp(c1,c2,l);}
   278 #pragma clang diagnostic pop   334         int l=(int)fread(bb,1,200,f);
   347         char message[2000],*s1=(
char*)
"",*s3=(
char*)
""; 
XMLCSTR s2=
_CXML(
"");
   351             "XML Parsing error inside file '%S'.\n%S\nAt line %i, column %i.\n%s%S%s"   353             "XML Parsing error inside file '%s'.\n%s\nAt line %i, column %i.\n%s%s%s"   358 #if defined(_XMLWINDOWS) && !defined(UNDER_CE) && !defined(_XMLPARSER_NO_MESSAGEBOX_)   359         MessageBoxA(NULL,message,
"XML Parsing error",MB_OK|MB_ICONERROR|MB_TOPMOST);
   361         printf(
"%s",message);
   384     0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
   385     1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
   386     1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
   387     1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
   388     1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
   389     1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
   390     1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
   391     1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
   392     1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
   393     1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
   394     1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
   395     1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
   396     1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
   397     2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
   398     3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,
   399     4,4,4,4,4,1,1,1,1,1,1,1,1,1,1,1 
   403     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,
   404     1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
   405     1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
   406     1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
   407     1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
   408     1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
   413     0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
   414     1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
   415     1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
   416     1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
   417     1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
   418     1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
   419     1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
   420     1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
   421     1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
   422     2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
   423     1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
   424     1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
   425     1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
   426     1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
   427     2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
   428     1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 
   433     0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
   434     1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
   435     1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
   436     1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
   437     1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
   438     1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
   439     1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
   440     1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
   441     1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
   442     1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
   443     1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
   444     2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
   445     2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
   446     2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
   447     2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
   448     2,2,2,2,2,2,2,2,1,1,1,1,1,1,1,1 
   453     0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
   454     1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
   455     1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
   456     1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
   457     1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
   458     1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
   459     1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
   460     1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
   461     1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
   462     2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
   463     2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
   464     2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
   465     2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
   466     2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
   467     2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
   468     2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1 
   535     unsigned char h[2]={ 0xFF, 0xFE };
   539         if (!fwrite(L
"<?xml version=\"1.0\" encoding=\"utf-16\"?>\n",
sizeof(
wchar_t)*40,1,f))
   552         if (!encoding) encoding=
"ISO-8859-1";
   573     if (lpszData==NULL) 
return NULL;
   576     if (cbData==-1) cbData=(int)
xstrlen(lpszData);
   581         lpszNew[cbData] = (
XMLCHAR)NULL;
   591     while ((ch=*
source)!=
'\0')
   596             if (ch==entity->
c) {
xstrcpy(dest,entity->
s); dest+=entity->
l; 
source++; 
goto out_of_loop1; }
   604         case 4: *(dest++)=*(
source++);
   605         case 3: *(dest++)=*(
source++);
   606         case 2: *(dest++)=*(
source++);
   607         case 1: *(dest++)=*(
source++);
   623     while ((ch=*
source)!=
'\0')
   628             if (ch==entity->
c) { 
r+=entity->
l; 
source++; 
goto out_of_loop1; }
   671             if ((lo>2)&&(
s[1]==
_CXML(
'#')))
   675                 while ((*
s)&&(*
s!=
_CXML(
';'))&&((lo--)>0)) 
s++;
   687                     if ((lo>=entity->
l)&&(
xstrnicmp(
s,entity->
s,entity->
l)==0)) { 
s+=entity->
l; lo-=entity->
l; 
break; }
   713             if (ss[1]==
_CXML(
'#'))
   719                     while (*ss!=
_CXML(
';'))
   722                         else if ((*ss>=
_CXML(
'A'))&&(*ss<=
_CXML(
'F'))) j=(j<<4)+*ss-
_CXML(
'A')+10;
   723                         else if ((*ss>=
_CXML(
'a'))&&(*ss<=
_CXML(
'f'))) j=(j<<4)+*ss-
_CXML(
'a')+10;
   729                     while (*ss!=
_CXML(
';'))
   745                     if (
xstrnicmp(ss,entity->
s,entity->
l)==0) { *(d++)=entity->
c; ss+=entity->
l; 
break; }
   756             case 4: *(d++)=*(ss++); ll--;
   757             case 3: *(d++)=*(ss++); ll--;
   758             case 2: *(d++)=*(ss++); ll--;
   759             case 1: *(d++)=*(ss++);
   768 #define XML_isSPACECHAR(ch) ((ch==_CXML('\n'))||(ch==_CXML(' '))||(ch== _CXML('\t'))||(ch==_CXML('\r')))   776     if (!cclose) 
return 1;
   778     if (
xstrnicmp(cclose, copen, l)!=0) 
return 1;
   784         (
c==
_CXML(
'=' ))) 
return 0;
   793     if (ch!=0) pXML->
nIndex++;
   807     int              indexStart,nFoundMatch,nIsText=
FALSE;
   849                 if (ch==chTemp) { nFoundMatch = 
TRUE; 
break; }
   850                 if (ch==
_CXML(
'<')) 
break;
   854             if (nFoundMatch == 
FALSE)
   856                 pXML->
nIndex=indexStart+1;
   884             if (chTemp == 
_CXML(
'/'))
   892             else if (chTemp == 
_CXML(
'?'))
   914             if (chTemp == 
_CXML(
'>'))
   941                 } 
else if (ch==
_CXML(
'/'))
   955         *pcbToken = pXML->
nIndex-indexStart;
   969     if (!
d) { free(lpszName); 
return NULL; }
   970     if (
d->lpszName&&(lpszName!=
d->lpszName)) free((
void*)
d->lpszName);
   971     d->lpszName=lpszName;
   990     d->pParent = pParent;
  1003 #define MEMORYINCREASE 50  1006 static inline void *
myRealloc(
void *
p, 
int newsize, 
int memInc, 
int sizeofElem)
  1008     if (
p==NULL) { 
if (memInc) 
return malloc(memInc*sizeofElem); 
return malloc(sizeofElem); }
  1009     if ((memInc==0)||((newsize%memInc)==0)) 
p=realloc(
p,(newsize+memInc)*sizeofElem);
  1020     if (
index<0) 
return -1;
  1021     int i=0,j=(int)((
index<<2)+xxtype),*o=
d->pOrder; while (o[i]!=j) i++; 
return i;
  1029     memmove(o+i, o+i+1, (
n-i)*
sizeof(
int));
  1031         if ((o[i]&3)==(
int)
t) o[i]-=4;
  1044     int n=
d->nChild+
d->nText+
d->nClear;
  1045     d->pOrder=(
int*)
myRealloc(
d->pOrder,
n+1,memoryIncrease*3,
sizeof(
int));
  1046     int pos=*_pos,*o=
d->pOrder;
  1048     if ((pos<0)||(pos>=
n)) { *_pos=nc; o[
n]=(int)((nc<<2)+xtype); 
return p; }
  1051     memmove(o+i+1, o+i, (
n-i)*
sizeof(
int));
  1053     while ((pos<
n)&&((o[pos]&3)!=(
int)xtype)) pos++;
  1054     if (pos==
n) { *_pos=nc; o[
n]=(int)((nc<<2)+xtype); 
return p; }
  1057     for (i=pos+1;i<=
n;i++) 
if ((o[i]&3)==(int)xtype) o[i]+=4;
  1059     *_pos=pos=o[pos]>>2;
  1060     memmove(((
char*)
p)+(pos+1)*
size,((
char*)
p)+pos*
size,(nc-pos)*
size);
  1070     d->pChild[pos].d=NULL;
  1073     return d->pChild[pos];
  1081     int nc=
d->nAttribute;
  1093     if (!lpszValue) 
return NULL;
  1094     if (!
d) { 
myFree(lpszValue); 
return NULL; }
  1096     d->pText[pos]=lpszValue;
  1136             else if (*pCh==
_CXML(
'>')) { lpszTemp=pCh; 
break; }
  1148         cbTemp = (int)(lpszTemp - lpXML);
  1164     if (
d->pOrder)     
d->pOrder=(
int*)realloc(
d->pOrder,(
d->nChild+
d->nText+
d->nClear)*
sizeof(int));
  1175     if (!lpszText) 
return 0;
  1177     int cbText = (int)(tokenPStr - lpszText);
  1178     if (!cbText) { pXML->
lpszText=NULL; 
return 0; }
  1180     if (!cbText) { pXML->
lpszText=NULL; 
return 0; }
  1188         int n=
d->nChild+
d->nText+
d->nClear-1,*o=
d->pOrder;
  1199                 if (!
d->pText[i]) 
return 1;
  1288 #ifdef APPROXIMATE_PARSING  1386                     lpszTemp = token.
pStr;
  1401 #ifdef STRICT_PARSING  1451                         lpszTemp = token.
pStr;
  1496                         lpszTemp = token.
pStr;
  1508                         if (
d->isDeclaration &&
  1509                             (lpszTemp[cbTemp-1]) == 
_CXML(
'?'))
  1564                         if (
d->isDeclaration &&
  1578                                 if (!attrVal) 
return FALSE;
  1606             if ((!
d->isDeclaration)&&(
d->pParent))
  1608 #ifdef STRICT_PARSING  1630     pResults->
nLine = 1;
  1710     if (pResults) { pResults->
nLine=0; pResults->
nColumn=0; }
  1714     int l=ftell(f),headerSz=0;
  1717     unsigned char *buf=(
unsigned char*)malloc(l+4);
  1718     int really_read = (int)fread(buf,1,l,f);            
  1719     if (really_read!=l) buf[0]=
'\0';
  1721     buf[l]=0;buf[l+1]=0;buf[l+2]=0;buf[l+3]=0;
  1729             XMLSTR b2=myMultiByteToWideChar((
const char*)(buf+headerSz),ce);
  1730             free(buf); buf=(
unsigned char*)
b2; headerSz=0;
  1733             if ((buf[0]==0xef)&&(buf[1]==0xff)) headerSz=2;
  1734             if ((buf[0]==0xff)&&(buf[1]==0xfe)) headerSz=2;
  1742             if ((buf[0]==0xef)&&(buf[1]==0xff)) headerSz=2;
  1743             if ((buf[0]==0xff)&&(buf[1]==0xfe)) headerSz=2;
  1745             free(buf); buf=(
unsigned char*)
b2; headerSz=0;
  1748             if ((buf[0]==0xef)&&(buf[1]==0xbb)&&(buf[2]==0xbf)) headerSz=3;
  1769     int cb=nFormat<0?0:nFormat;
  1771     int nChildFormat=-1;
  1772     int nElementI=pEntry->nChild+pEntry->nText+pEntry->nClear;
  1774     if ((nFormat>=0)&&(nElementI==1)&&(pEntry->nText==1)&&(!pEntry->isDeclaration)) nFormat=-2;
  1778 #define LENSTR(lpsz) (lpsz ? xstrlen(lpsz) : 0)  1781     cbElement = (int)
LENSTR(pEntry->lpszName);
  1790             lpszMarker[nResult++]=
_CXML(
'<');
  1791             if (pEntry->isDeclaration) lpszMarker[nResult++]=
_CXML(
'?');
  1792             xstrcpy(&lpszMarker[nResult], pEntry->lpszName);
  1794             lpszMarker[nResult++]=
_CXML(
' ');
  1798             nResult+=cbElement+2+cb;
  1799             if (pEntry->isDeclaration) nResult++;
  1804         for (i=0; i<pEntry->nAttribute; i++)
  1818                         lpszMarker[nResult]=
_CXML(
'=');
  1819                         lpszMarker[nResult+1]=
_CXML(
'"');
  1821                         lpszMarker[nResult+cb+2]=
_CXML(
'"');
  1825                 if (lpszMarker) lpszMarker[nResult] = 
_CXML(
' ');
  1831         if (pEntry->isDeclaration)
  1835                 lpszMarker[nResult-1]=
_CXML(
'?');
  1836                 lpszMarker[nResult]=
_CXML(
'>');
  1841                 if (lpszMarker) lpszMarker[nResult]=
_CXML(
'\n');
  1848                 if (lpszMarker) lpszMarker[nResult-1]=
_CXML(
'>');
  1851                     if (lpszMarker) lpszMarker[nResult]=
_CXML(
'\n');
  1861         if (cbElement&&(!pEntry->isDeclaration)) nChildFormat=nFormat+1;
  1862         else nChildFormat=nFormat;
  1866     for (i=0; i<nElementI; i++)
  1868         j=pEntry->pOrder[i];
  1875                 XMLCSTR pChild=pEntry->pText[j>>2];
  1885                             lpszMarker[nResult+nFormat+1+cb]=
_CXML(
'\n');
  1887                         nResult+=cb+nFormat+2;
  1900                 XMLClear *pChild=pEntry->pClear+(j>>2);
  1912                         nResult+=cb+nFormat+1;
  1939                     if (lpszMarker) lpszMarker[nResult] = 
_CXML(
'\n');
  1949                 nResult += 
CreateXMLStringR(pEntry->pChild[j>>2].d, lpszMarker ? lpszMarker + nResult : 0, nChildFormat);
  1956     if ((cbElement)&&(!pEntry->isDeclaration))
  1971                 lpszMarker[nResult]=
_CXML(
'<'); lpszMarker[nResult+1]=
_CXML(
'/');
  1973                 xstrcpy(&lpszMarker[nResult], pEntry->lpszName);
  1974                 nResult += cbElement;
  1976                 lpszMarker[nResult]=
_CXML(
'>');
  1977                 if (nFormat == -1) nResult++;
  1980                     lpszMarker[nResult+1]=
_CXML(
'\n');
  1985                 if (nFormat>=0) nResult+=cbElement+4+nFormat;
  1986                 else if (nFormat==-1) nResult+=cbElement+3;
  1987                 else nResult+=cbElement+4;
  1996                 lpszMarker[nResult]=
_CXML(
'/'); lpszMarker[nResult+1]=
_CXML(
'>');
  1997                 if (nFormat != -1) lpszMarker[nResult+2]=
_CXML(
'\n');
  1999             nResult += nFormat == -1 ? 2 : 3;
  2019     if (!
d) { 
if (pnSize) *pnSize=0; 
return NULL; }
  2021     XMLSTR lpszResult = NULL;
  2026     nFormat = nFormat ? 0 : -1;
  2032     lpszResult[cbStr]=
_CXML(
'\0');
  2033     if (pnSize) *pnSize = cbStr;
  2041     while (((
void*)(pa[i].
d))!=((
void*)
d)) i++;
  2042     d->pParent->nChild--;
  2043     if (
d->pParent->nChild) memmove(pa+i,pa+i+1,(
d->pParent->nChild-i)*
sizeof(
XMLNode));
  2044     else { free(pa); 
d->pParent->pChild=NULL; }
  2063     if ((dd->ref_count==0)||force)
  2068         for(i=0; i<dd->nChild; i++)
  2071             pc->
d->pParent=NULL;
  2076         for(i=0; i<dd->nText; i++) free((
void*)dd->pText[i]);
  2078         for(i=0; i<dd->nClear; i++) free((
void*)dd->pClear[i].lpszValue);
  2080         for(i=0; i<dd->nAttribute; i++)
  2082             free((
void*)dd->pAttribute[i].lpszName);
  2083             if (dd->pAttribute[i].lpszValue) free((
void*)dd->pAttribute[i].lpszValue);
  2087         myFree((
void*)dd->lpszName);
  2088         dd->nChild=0;    dd->nText=0;    dd->nClear=0;    dd->nAttribute=0;
  2089         dd->pChild=NULL; dd->pText=NULL; dd->pClear=NULL; dd->pAttribute=NULL;
  2090         dd->pOrder=NULL; dd->lpszName=NULL; dd->pParent=NULL;
  2092     if (dd->ref_count==0)
  2106         if (
d) (
d->ref_count) ++ ;
  2115     if (
d) (
d->ref_count)++ ;
  2123     int n=
d->nAttribute;
  2129             p->pAttribute[
n].lpszName=
stringDup(
d->pAttribute[
n].lpszName);
  2130             p->pAttribute[
n].lpszValue=
stringDup(
d->pAttribute[
n].lpszValue);
  2135         n=(
d->nChild+
d->nText+
d->nClear)*
sizeof(
int); 
p->pOrder=(
int*)malloc(
n); 
memcpy(
p->pOrder,
d->pOrder,
n);
  2149             p->pClear[
n].lpszCloseTag=
d->pClear[
n].lpszCloseTag;
  2150             p->pClear[
n].lpszOpenTag=
d->pClear[
n].lpszOpenTag;
  2160             p->pChild[
n].d=NULL;
  2161             p->pChild[
n]=
d->pChild[
n].deepCopy();
  2162             p->pChild[
n].d->pParent=
p;
  2171     if ((!dc)||(!
d)) 
return childNode;
  2183     if (dc->pParent) { 
if ((
detachFromParent(dc)<=pos)&&(dc->pParent==
d)) pos--; } 
else dc->ref_count++;
  2188     d->pChild[pos].d=dc;
  2195     if ((!
d)||(i<0)||(i>=
d->nAttribute)) 
return;
  2198     free((
void*)
p->lpszName);
  2199     if (
p->lpszValue) free((
void*)
p->lpszValue);
  2200     if (
d->nAttribute) memmove(
p,
p+1,(
d->nAttribute-i)*
sizeof(
XMLAttribute)); 
else { free(
p); 
d->pAttribute=NULL; }
  2213     if (!
d) { 
if (lpszNewValue) free(lpszNewValue); 
if (lpszNewName) free(lpszNewName); 
return NULL; }
  2214     if (i>=
d->nAttribute)
  2220     if (
p->lpszValue&&
p->lpszValue!=lpszNewValue) free((
void*)
p->lpszValue);
  2221     p->lpszValue=lpszNewValue;
  2222     if (lpszNewName&&
p->lpszName!=lpszNewName) { free((
void*)
p->lpszName); 
p->lpszName=lpszNewName; };
  2248     if (!lpszValue) { 
if (l) 
return 0; 
return -1; }
  2250     for (i=0; i<l; i++) 
if (lpszValue==
p[i]) 
return i;
  2256     if ((!
d)||(i<0)||(i>=
d->nText)) 
return;
  2260     if (
d->nText) memmove(
p,
p+1,(
d->nText-i)*
sizeof(
XMLCSTR)); 
else { free(
p); 
d->pText=NULL; }
  2268     if (!
d) { 
if (lpszNewValue) free(lpszNewValue); 
return NULL; }
  2271     if (*
p!=lpszNewValue) { free((
void*)*
p); *
p=lpszNewValue; }
  2272     return lpszNewValue;
  2277     if (!
d) { 
if (lpszNewValue) free(lpszNewValue); 
return NULL; }
  2285     if ((!
d)||(i<0)||(i>=
d->nClear)) 
return;
  2288     free((
void*)
p->lpszValue);
  2289     if (
d->nClear) memmove(
p,
p+1,(
d->nClear-i)*
sizeof(
XMLClear)); 
else { free(
p); 
d->pClear=NULL; }
  2297     if (!lpszValue) { 
if (l) 
return 0; 
return -1; }
  2299     for (i=0; i<l; i++) 
if (lpszValue==
p[i].lpszValue) 
return i;
  2308     if (!
d) { 
if (lpszNewContent) free(lpszNewContent); 
return NULL; }
  2311     if (lpszNewContent!=
p->lpszValue) { free((
void*)
p->lpszValue); 
p->lpszValue=lpszNewContent; }
  2317     if (!
d) { 
if (lpszNewContent) free(lpszNewContent); 
return NULL; }
  2332     int i,j=0,
n=
d->nChild;
  2345     int i=0,
n=
d->nChild;
  2370     while (i--) 
if (!
xstricmp(
name,
d->pChild[i].d->lpszName)) 
break;
  2379     if (path) free(path);
  2385     if ((!path)||(!(*path))) 
return *
this;
  2387     XMLCHAR *tend1,sepString[2]; sepString[0]=sep; sepString[1]=0;
  2388     tend1=
xstrstr(path,sepString);
  2395             if (createIfMissing) xn=xbase.
addChild(path);
  2400         tend1=
xstrstr(path,sepString);
  2415     if ((!
d)||(!
x.d)) 
return -1;
  2446                      t=
x.getAttribute(attributeName,&j);
  2447                      if (
t&&(
xstricmp(attributeValue,
t)==0)) { 
if (k) *k=i; 
return x; }
  2451                  if (
x.isAttributeSet(attributeName)) { 
if (k) *k=i; 
return x; }
  2454      } 
while (!
x.isEmpty());
  2461     if (!
d) 
return NULL;
  2462     int i=0,
n=
d->nAttribute;
  2480     int i,
n=
d->nAttribute;
  2495     if (!
d) 
return NULL;
  2508         c.attrib=
d->pAttribute[i];
  2513     i=(
d->pOrder[i])>>2;
  2556               { 
return addClear_priv(0,lpszValue,lpszOpen,lpszClose,pos); }
  2577                                char _dropWhiteSpace, 
char _removeCommentsInMiddleOfText)
  2583     switch(_characterEncoding)
  2604     unsigned char *
b=(
unsigned char*)buf;
  2619     if (!useXMLEncodingAttribute) 
return bestGuess;
  2626     b=(
unsigned char*)strstr(bb,
"encoding");
  2627     if (!
b) 
return bestGuess;
  2650 #undef XML_isSPACECHAR  2664     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,  
  2665     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,  
  2666     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,  
  2667     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,  
  2668     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,  
  2669     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,  
  2670     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,  
  2671     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,  
  2672     98,98,98,98,98,98,98,98,98,98,  98,98,98,98,98,98                                               
  2681     unsigned int i=((inlen-1)/3*4+4+1);
  2682     if (formatted) i+=inlen/54;
  2688     int i=
encodeLength(inlen,formatted),k=17,eLen=inlen/3,j;
  2694         j=(inbuf[0]<<16)|(inbuf[1]<<8)|inbuf[2]; inbuf+=3;
  2700         if (formatted) { 
if (!k) { *(curr++)=
_CXML(
'\n'); k=18; } k--; }
  2711         j=(inbuf[0]<<8)|inbuf[1];
  2738     if (
size==0) 
return 0;
  2740     return (
unsigned int)((
size*3)/4);
  2752 #define BASE64DECODE_READ_NEXT_CHAR(c)                                              \  2754             if (data[i]>255){ c=98; break; }                                        \  2755             c=base64DecodeTable[(unsigned char)data[i++]];                       \  2757         if(c==98){ if(xe)*xe=eXMLErrorBase64DecodeIllegalCharacter; return 0; }  2759 #define BASE64DECODE_READ_NEXT_CHAR(c)                                           \  2760         do { c=base64DecodeTable[(unsigned char)data[i++]]; }while (c==97);   \  2761         if(c==98){ if(xe)*xe=eXMLErrorBase64DecodeIllegalCharacter; return 0; }  2765         if (
c==99) { 
return 2; }
  2768             if (
p==(
int)
len) 
return 2;
  2776         buf[
p++]=(
unsigned char)((
c<<2)|((d>>4)&0x3));
  2782             if (
c==96) 
return 2;
  2787         buf[
p++]=(
unsigned char)(((d<<4)&0xf0)|((
c>>2)&0xf));
  2793             if (d==96) 
return 2;
  2798         buf[
p++]=(
unsigned char)(((
c<<6)&0xc0)|d);
  2801 #undef BASE64DECODE_READ_NEXT_CHAR  2805     if ((!
buf)&&(newsize)) { 
buf=malloc(newsize); 
buflen=newsize; 
return; }
  2813     if (outlen) *outlen=
len;
  2814     if (!
len) 
return NULL;
  2817     return (
unsigned char*)
buf;
 
void BASE_IMPEXP memcpy(void *dest, size_t destSize, const void *src, size_t copyCount) MRPT_NO_THROWS
An OS and compiler independent version of "memcpy". 
 
static XMLCSTR getVersion()
Return the XMLParser library version number. 
 
int nAttribute() const
nbr of attribute 
 
char isAttributeSet(XMLCSTR name) const
test if an attribute with a specific name is given 
 
static const char XML_gbk_big5_ByteTable[256]
 
GLuint GLuint GLsizei count
 
FILE BASE_IMPEXP * fopen(const char *fileName, const char *mode) MRPT_NO_THROWS
An OS-independent version of fopen. 
 
XMLCSTR updateName_WOSD(XMLSTR lpszName)
change node's name 
 
XMLNode getParentNode() const
return the parent node 
 
XMLElementType
Enumeration used to manage type of data. Use in conjunction with structure XMLNodeContents. 
 
XMLCSTR base64EncodeTable
 
XMLCHAR xmltoc(XMLCSTR t, XMLCHAR v)
 
static ALLXMLClearTag XMLClearTags[]
 
char maybeAddTxT(void *pa, XMLCSTR tokenPStr)
 
void deleteAttribute(int i=0)
Delete the ith attribute of the current XMLNode. 
 
Main Class representing a XML node. 
 
static void myFree(void *p)
 
XMLClear * addClear_WOSD(XMLSTR lpszValue, XMLCSTR lpszOpen=NULL, XMLCSTR lpszClose=NULL, XMLElementPosition pos=-1)
Add a new clear Tag. 
 
static XMLSTR xstrstr(XMLCSTR c1, XMLCSTR c2)
 
XMLClear * updateClear(XMLCSTR lpszNewContent, int i=0)
if the clearTag to update is missing, a new one will be added 
 
int BASE_IMPEXP void BASE_IMPEXP fclose(FILE *f)
An OS-independent version of fclose. 
 
XMLCharEncoding
Enumeration for XML character encoding. 
 
XMLNode getChildNodeByPath(XMLSTR path, char createNodeIfMissing=0, XMLCHAR sep='/')
return the first child node with specific path. WARNING: the value of the parameter "path" is destroy...
 
XMLCSTR updateText(XMLCSTR lpszNewValue, int i=0)
if the text to update is missing, a new one will be added 
 
Structure for XML clear (unformatted) node (usually comments) 
 
static XMLNode parseString(XMLCSTR lpXMLString, XMLCSTR tag=NULL, XMLResults *pResults=NULL)
Parse an XML string and return the root of a XMLNode tree representing the string. 
 
void * addToOrder(int memInc, int *_pos, int nc, void *p, int size, XMLElementType xtype)
 
char isEmpty() const
is this node Empty? 
 
This structure is given by the function XMLNode::enumContents. 
 
static int xstrnicmp(XMLCSTR c1, XMLCSTR c2, int l)
 
XMLSTR stringDup(XMLCSTR lpszData, int cbData)
Duplicate (copy in a new allocated buffer) the source string. 
 
static XMLNode createXMLTopNode(XMLCSTR lpszName, char isDeclaration=FALSE)
Create the top node of an XMLNode structure. 
 
int XMLElementPosition
XMLElementPosition are not interchangeable with simple indexes. 
 
int nClear() const
nbr of clear field 
 
int BASE_IMPEXP fprintf(FILE *fil, const char *format,...) MRPT_NO_THROWS MRPT_printf_format_check(2
An OS-independent version of fprintf. 
 
XMLNode addChild_priv(int, XMLSTR, char, int)
 
static void * myRealloc(void *p, int newsize, int memInc, int sizeofElem)
 
XMLAttribute * addAttribute_priv(int, XMLSTR, XMLSTR)
 
static int removeOrderElement(XMLNodeData *d, XMLElementType t, int index)
 
XMLElementPosition positionOfChildNode(int i=0) const
 
char BASE_IMPEXP * strcpy(char *dest, size_t destSize, const char *source) MRPT_NO_THROWS
An OS-independent version of strcpy. 
 
static const char XML_gb2312ByteTable[256]
 
static int xstrncmp(XMLCSTR c1, XMLCSTR c2, int l)
 
static XMLClear emptyXMLClear
 
void deleteText(int i=0)
Delete the Ith text content of the current XMLNode. 
 
#define BASE64DECODE_READ_NEXT_CHAR(c)
 
XMLNode & operator=(const XMLNode &A)
to allow shallow/fast copy: 
 
int ParseXMLElement(void *pXML)
 
static XMLCSTR getError(XMLError error)
this gives you a user-friendly explanation of the parsing error 
 
int mmin(const int t1, const int t2)
 
int nChildNode() const
nbr of child node 
 
XMLCSTR getText(int i=0) const
return ith text field 
 
struct XMLAttribute XMLAttribute
Structure for XML attribute. 
 
int nText() const
nbr of text field 
 
static XMLNode createXMLTopNode_WOSD(XMLSTR lpszName, char isDeclaration=FALSE)
Create the top node of an XMLNode structure. 
 
XMLCSTR addText_WOSD(XMLSTR lpszValue, XMLElementPosition pos=-1)
Add a new text content. 
 
XMLAttribute getAttribute(int i=0) const
return ith attribute 
 
static NextToken GetNextToken(XML *pXML, int *pcbToken, enum XMLTokenTypeTag *pType)
 
XMLNode getChildNodeWithAttribute(XMLCSTR tagName, XMLCSTR attributeName, XMLCSTR attributeValue=NULL, int *i=NULL) const
return child node with specific name/attribute (return an empty node if failing) 
 
XMLCSTR addText_priv(int, XMLSTR, int)
 
int nElement() const
nbr of different contents for current node 
 
static XMLCHAR getNextChar(XML *pXML)
 
XMLNode addChild_WOSD(XMLSTR lpszName, char isDeclaration=FALSE, XMLElementPosition pos=-1)
Add a new child node. 
 
void emptyTheNode(char force)
 
XMLError
Enumeration for XML parse errors. 
 
XMLCSTR xmltoa(XMLCSTR t, XMLCSTR v)
 
static XMLNode openFileHelper(XMLCSTR filename, XMLCSTR tag=NULL)
Parse an XML file and return the root of a XMLNode tree representing the file. A very crude error che...
 
void deleteNodeContent()
The "deleteNodeContent" function forces the deletion of the content of this XMLNode and the subtree...
 
static int detachFromParent(XMLNodeData *d)
 
int indexClear(XMLCSTR lpszValue) const
 
static XMLNode::XMLCharEncoding characterEncoding
 
static char setGlobalOptions(XMLCharEncoding characterEncoding=XMLNode::char_encoding_UTF8, char guessWideCharChars=1, char dropWhiteSpace=1, char removeCommentsInMiddleOfText=1)
Sets the global options for the conversions. 
 
XMLAttribute * updateAttribute_WOSD(XMLAttribute *newAttribute, XMLAttribute *oldAttribute)
if the attribute to update is missing, a new one will be added 
 
XMLCSTR updateName(XMLCSTR lpszName)
change node's name 
 
XMLNodeContents enumContents(XMLElementPosition i) const
enumerate all the different contents (attribute,child,text, clear) of the current XMLNode...
 
static XMLNode emptyNode()
return XMLNode::emptyXMLNode; 
 
#define XML_isSPACECHAR(ch)
 
XMLElementPosition positionOfText(int i=0) const
 
XMLElementPosition positionOfClear(int i=0) const
 
static void charmemset(XMLSTR dest, XMLCHAR c, int l)
 
static char dropWhiteSpace
 
static void CountLinesAndColumns(XMLCSTR lpXML, int nUpto, XMLResults *pResults)
 
static XMLElementPosition findPosition(XMLNodeData *d, int index, XMLElementType xtype)
 
static int xstricmp(XMLCSTR c1, XMLCSTR c2)
 
struct XMLNode::XMLNodeDataTag XMLNodeData
 
static XMLAttribute emptyXMLAttribute
 
static XMLSTR xstrcpy(XMLSTR c1, XMLCSTR c2)
 
static const char XML_sjisByteTable[256]
 
static XMLCharacterEntity XMLEntities[]
 
static void exactMemory(XMLNodeData *d)
 
static FILE * xfopen(XMLCSTR filename, XMLCSTR mode)
 
static XMLCharEncoding guessCharEncoding(void *buffer, int bufLen, char useXMLEncodingAttribute=1)
Guess the character encoding of the string (ascii, utf8 or shift-JIS) 
 
XMLAttribute * updateAttribute(XMLAttribute *newAttribute, XMLAttribute *oldAttribute)
if the attribute to update is missing, a new one will be added 
 
XMLCSTR addText(XMLCSTR lpszValue, XMLElementPosition pos=-1)
Add a new text content. 
 
int indexText(XMLCSTR lpszValue) const
 
XMLClear * addClear(XMLCSTR lpszValue, XMLCSTR lpszOpen=NULL, XMLCSTR lpszClose=NULL, XMLElementPosition pos=-1)
Add a new clear tag. 
 
XMLAttribute * addAttribute_WOSD(XMLSTR lpszName, XMLSTR lpszValue)
Add a new attribute. 
 
XMLCSTR updateText_WOSD(XMLSTR lpszNewValue, int i=0)
if the text to update is missing, a new one will be added 
 
GLdouble GLdouble GLdouble r
 
char parseClearTag(void *px, void *pa)
 
static const char * XML_ByteTable
 
static const char base64Fillchar
 
static const char XML_utf8ByteTable[256]
 
XMLClear * updateClear_WOSD(XMLSTR lpszNewContent, int i=0)
if the clearTag to update is missing, a new one will be added 
 
char myTagCompare(XMLCSTR cclose, XMLCSTR copen)
 
char xmltob(XMLCSTR t, char v)
 
GLuint const GLchar * name
 
GLsizei GLsizei GLchar * source
 
Structure for XML attribute. 
 
const unsigned char base64DecodeTable[]
 
static char guessWideCharChars
 
int BASE_IMPEXP sprintf(char *buf, size_t bufSize, const char *format,...) MRPT_NO_THROWS MRPT_printf_format_check(3
An OS-independent version of sprintf (Notice the bufSize param, which may be ignored in some compiler...
 
XMLError writeToFile(XMLCSTR filename, const char *encoding=NULL, char nFormat=1) const
Save the content of an xmlNode inside a file. 
 
char myIsTextWideChar(const void *b, int l)
 
static XMLNode parseFile(XMLCSTR filename, XMLCSTR tag=NULL, XMLResults *pResults=NULL)
Parse an XML file and return the root of a XMLNode tree representing the file. 
 
XMLNode addChild(XMLCSTR lpszName, char isDeclaration=FALSE, XMLElementPosition pos=-1)
Add a new child node. 
 
static int CreateXMLStringR(XMLNodeData *pEntry, XMLSTR lpszMarker, int nFormat)
 
long xmltol(XMLCSTR t, long v)
 
enum XMLTokenTypeTag XMLTokenType
 
XMLClear getClear(int i=0) const
return ith clear field (comments) 
 
static char removeCommentsInMiddleOfText
 
XMLCSTR getAttributeValue(int i=0) const
return ith attribute value 
 
static XMLNode emptyXMLNode
 
char isDeclaration() const
is this node a declaration <? .... ?> 
 
char * myWideCharToMultiByte(const wchar_t *s)
 
GLsizei GLsizei GLenum GLenum const GLvoid * data
 
GLubyte GLubyte GLubyte a
 
int BASE_IMPEXP _strnicmp(const char *str, const char *subStr, size_t count) MRPT_NO_THROWS
An OS-independent version of strnicmp. 
 
XMLCSTR getAttributeName(int i=0) const
return ith attribute name 
 
void freeXMLString(XMLSTR t)
to free the string allocated inside the "stringDup" function or the "createXMLString" function...
 
void deleteClear(int i=0)
Delete the Ith clear tag inside the current XMLNode. 
 
int nChildNode(XMLCSTR name) const
return the number of child node with specific name 
 
XMLNode deepCopy() const
deep copy (duplicate/clone) a XMLNode 
 
Structure used to obtain error details if the parse fails. 
 
double xmltof(XMLCSTR t, double v)
 
static int xstrlen(XMLCSTR c)
 
int xmltoi(XMLCSTR t, int v)
 
XMLSTR fromXMLString(XMLCSTR s, int lo, XML *pXML)
 
XMLCSTR getName() const
name of the node 
 
XMLNode getChildNode(int i=0) const
return ith child node 
 
XMLAttribute * addAttribute(XMLCSTR lpszName, XMLCSTR lpszValuev)
Add a new attribute. 
 
static const char XML_legacyByteTable[256]
 
XMLClear * addClear_priv(int, XMLSTR, XMLCSTR, XMLCSTR, int)
 
XMLSTR createXMLString(int nFormat=1, int *pnSize=NULL) const
Create an XML string starting from the current XMLNode.